Plotting outputs from a function on one figure using for loop
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I need help with the following question please, I am calculating the outputs for this function at different friction and initial elevation values, and I would like to plot all of them on one graph, sor for instance I need to plot x_direction vs y_direction for every friction value
function[v_a, x_direction, y_direction, v_b, t_flight]=func(friction, initialelevation)
friction= 0.1 : 0.05 : 0.65
initialelevation= 100 : 15 : 200
% this is what i am using so far but not sure how to put the plotting in there
for j = 1:friction
for n = 1:initialelevation
[v_a(j,n), x_direction(j,n), y_direction(j,n), v_b(j,n), t_flight(j,n)] = func(friction(j), initialelevation(n));
end
end
Please help!!
0 件のコメント
回答 (1 件)
KSSV
2019 年 3 月 8 日
YOu should follow some thing like shown below:
friction= 0.1 : 0.05 : 0.65 ;
initialelevation= 100 : 15 : 200 ;
function[v_a, x_direction, y_direction, v_b, t_flight]=func(friction, initialelevation)
m = length(friction) ;
n = length(initialelevation) ;
v_a = zeros(m,n) ;
x_direction = zeros(m,n) ;
y_direction = zeros(m,n) ;
v_b = zeros(m,n) ;
t_flight = zeros(m,n) ;
% this is what i am using so far but not sure how to put the plotting in there
for i = 1:friction
for j = 1:initialelevation
[va, xdirection, ydirection, vb, tflight] = func(friction(i), initialelevation(j));
v_a(i,j) = va ;
x_direction(i,j) = xdirection ;
y_direction(i,j) = ydirection ;
v_b(i,j) = vb ;
t_flight(i,j) = tflight ;
end
end
4 件のコメント
KSSV
2019 年 3 月 8 日
YOu have entire data as matrrix outside....you can plot it outside. Read about plot
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!