Plotting output for a range of numbers
Show older comments
Hello,
It's been a while since I've used MATLAB on a daily basis and I'm having trouble with plotting the response of a system over a time interval depending on whether the time is less than or greater than a value.
My time interval is from 0 to 10 seconds with 0.1 second intervals. If t is less than 3 seconds I have one equation and if t is equal to or less than 3 I have a second equation. Any help would be greatly appreciated.
Answers (1)
madhan ravi
on 2 Nov 2018
Edited: madhan ravi
on 2 Nov 2018
t = 0 : 0.1 : 10;
for i = 1:numel(t)
if t(i)<=3
% eq1
eq1(i)=t(i).^2; %example
elseif
%eq2
eq2(i)=t(i).^3; %example
end
end
plot(t(1:numel(eq1)),eq1,'r')
hold on
plot(t(1:numel(eq2)),eq2,'m')
Categories
Find more on Get Started with Control System Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!