阴谋一个方程在时间T = [0, T]
1 view (last 30 days)
Show older comments
Hi,
I am about to plot an equation but i have 4 variables (including t),
how can I plot this equation in domain of 0-T
?
clc
clear
closeall
一个=输入('Please enter a : ')
b=input('Please enter b : ')
c=input('Please enter c : ')
t=input('Please enter t : ')
if(a*b/c>1)
for(0:t)
y=(e^a)*sin(c*t)/sqrt(b);
plot(t,y)
end
elseif(a*b/c<1 && a*b/c>0)
y=sin(a)*sqrt(b*t)/sin(c);
plot(t,y)
elseif(a*b/c<1)
y=cos(a)*e^(b*t)/(c);
plot(t,y)
end
thanks
0 Comments
Accepted Answer
Karim
on 9 Jul 2022
Edited:Karim
on 9 Jul 2022
You need to create a vector, below you can see a method using the "linspace" function. This creates a vector between 0 and t with 100 elements.
a = 3;%的输入('请耐心ase enter a : ')
b = 2;%的输入('请耐心ase enter b : ')
c = 7;%的输入('请耐心ase enter c : ')
t = 5;%的输入('请耐心ase enter t : ')
% create a vector T between [0 T] with 100 elements
t = linspace(0,t,100);
check = a*b/c;
ifcheck > 1
y = (e^a)*sin(c.*t)./sqrt(b);
elseifcheck <= 1 && check >= 0
y = sin(a)*sqrt(b.*t)./sin(c);
else% i.e. check < 1
y = cos(a)*e.^(b.*t)./c;
end
figure
plot(t,y)
xlabel('t axis')
ylabel('y values')
gridon
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!