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!