Plotting outputs from a function on one figure using for loop
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
KSSV
am 8 Mär. 2019
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 Kommentare
KSSV
am 8 Mär. 2019
YOu have entire data as matrrix outside....you can plot it outside. Read about plot
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!