Making A table and a plot from a for loop
6 ビュー (過去 30 日間)
古いコメントを表示
Hi,
Using data collected from the for loop, I have been trying to create
1) One table with 4 columns (t, v, a, h) , and
2) 3 different graphs with t on the x axis for all 3 graphs, and v, a, h on the y axis of the respective graph (ie. plot(t,v), plot(t,a), plot(t,h)).
Here is my loop:
for t= 0:4:80
t
a= u*(q/(wt-q*t))-g
v= u*log((wt)./(wt-q*t))- g*t
h= u*t - u*(((wt./q)-t).*log((wt)./(wt-q*t)))-0.5*g*t.^2
end
Here are the values:
wt=2400+2000;
q =25;
u =12000;
g =32.2;
I have tried multiple ways such as putting my data from the loop to an array and then making a table and 3 graphs, etc. However, it failed as I can't seem to store each of the variable values into an array. How can I solve this problem? Or is there another way to make the table and plot?
Please help.
0 件のコメント
採用された回答
Setsuna Yuuki.
2020 年 11 月 8 日
wt=2400+2000;
q =25;
u =12000;
g =32.2;
largo = 100;
a = zeros(1,largo);
v = zeros(1,largo);
h = zeros(1,largo);
for t = 0:1:largo
a(t+1)= u*(q/(wt-q*t))-g;
v(t+1)= u*log((wt)./(wt-q*t))- g*t;
h(t+1)= u*t - u*(((wt./q)-t).*log((wt)./(wt-q*t)))-0.5*g*t.^2;
end
t = 0:1:largo;
%% plot
figure
plot(t,a,'LineWidth',2);hold on;
plot(t,v,'LineWidth',2);
plot(t,h,'LineWidth',2);
ylim([0 2e3]); xlabel('time') %limits Y, name x
legend('a(t)','v(t)','h(t)') %name of curves
%% table
t = t'; a=a'; v=v'; h=h';
vectores = table(t,a,v,h);
1 件のコメント
Arshey Dhangekar
2021 年 5 月 29 日
How can we use loop for ploting grpah for two columns?
I want to plot graph time vs every M varibale(in .csv file) with as subplot and combined plot for all columns present in table
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!