Plotting output for a range of numbers

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.

Antworten (1)

madhan ravi
madhan ravi am 2 Nov. 2018
Bearbeitet: madhan ravi am 2 Nov. 2018

0 Stimmen

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')

Kategorien

Mehr zu Get Started with Control System Toolbox finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018b

Gefragt:

am 2 Nov. 2018

Bearbeitet:

am 2 Nov. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by