Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How can I plot my data from my for loop?
조회 수: 1 (최근 30일)
이전 댓글 표시
Please see my code below. I would like to plot v0 on the x-axis, and d on the y-axis.
I'm not really sure how I can save all of the data points from the for loop into plottable values.
clc
clear all
v0=50:1:100;
i=1
for i=1:length(v0);
syms t v0
eqn1 = (0 == v0-12.*(t-0.75)-v0+9.*t);
time=solve(eqn1,t)
syms d v0
eqn2 = (0 == ((v0.*0.75)+(v0.*time)-(v0.*0.75)+0.5.*(-12).*(time-0.75)^2-d-v0.*time+0.5.*(9).*time^2));
distance=solve(eqn2,d)
end
댓글 수: 0
답변 (1개)
Durganshu
2020년 10월 19일
I'm writing this answer on a mobile phone and thus, I havn't checked this code, but it should work:
clc
clear all
v0=50:1:100;
i=1
syms t v0
eqn1 = (0 == v0-12.*(t-0.75)-v0+9.*t);
time=solve(eqn1,t)
syms d v0
eqn2 = (0 == ((v0.*0.75)+(v0.*time)-(v0.*0.75)+0.5.*(-12).*(time-0.75)^2-d-v0.*time+0.5.*(9).*time^2));
distance=solve(eqn2,d)
plot(v0, distance);
hold on;
If it doesn't works, try putting the whole block inside for loop and iterate on individual values of v0. But, I think this method should also work.
You can also use fplot whose documentation can be found here: https://in.mathworks.com/help/matlab/ref/fplot.html
Hope that helps!
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!