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.

Réponses (1)

madhan ravi
madhan ravi le 2 Nov 2018
Modifié(e) : madhan ravi le 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')

Catégories

En savoir plus sur Get Started with Control System Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by