need help creating two nested for loops to run the function

조회 수: 1 (최근 30일)
william Smith
william Smith 2019년 3월 4일
편집: Stephen23 2019년 3월 4일
function[v_a, x_direction, y_direction, v_b, t_flight]=func(friction, initalelevation)
friction= 0.1 : 0.05 : 0.65
initial elevation= 100 : 15 : 200
Can you please provide me with an example to create "two nested for loops to run the function for all combinations of inputs given above" , I already have outputs equations assigned
Thanks!
  댓글 수: 2
Stephen23
Stephen23 2019년 3월 4일
편집: Stephen23 2019년 3월 4일
@william Smith: what have you tried so far? Did you search the internet for "MATLAB nested loops"? What is the exact problem that you are having that you are unable to solve?
Note that very basic MATLAB concepts, such as how to call functions and write loops, are explained in the introductory tutorials:
william Smith
william Smith 2019년 3월 4일
편집: Stephen23 2019년 3월 4일
function[v_a, x_direction, y_direction, v_b, t_flight]=func(friction, initalelevation)
for loss= 0.1:0.05:0.65
for initialheight=100:15:200
if x_direction(loss,initialheight)==0:500 && y_direction(loss,initialheight)==0:-134
v_a(loss+1,initialheight+1)=sum(v_x)+sum(v_y);
x_direction(loss+1,initialheight+1)=x_direction(loss+1,initialheight+1)+x_direction(loss+1,initialheight+1)*dt;
y_direction(loss+1,initialheight+1)=y_direction(loss+1,initialheight+1)+y_direction(loss+1,initialheight+1)*dt;
end
end
end
this is what I tried, when i call out my function it says undefined function or variable 'friction'

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by