How to make a matlab code decrease the values step by step and plot a graph?
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello sir, kindly share your suggestions to solve this problem, input is speed = 150 m/s, convert to km/hr =150*3.6 = 540 for minutes =540/60 = 9 range = 60
manually I done It
t0 = sqrt((5*9)*(5*9)+(60.^2)) = 75
t1 = sqrt((4*9)*(4*9)+(60.^2)) =69.9
t2 = sqrt((3*9)*(3*9)+(60.^2)) =65.7
t3 = sqrt((2*9)*(2*9)+(60.^2)) =62.6
t4 = sqrt((1*9)*(1*9)+(60.^2)) =60.6
t5 = sqrt((60.^2)) =60
t6 = sqrt((1*9)*(1*9)+(60.^2)) =60.6
t7 = sqrt((2*9)*(2*9)+(60.^2)) =62.6
t8 = sqrt((3*9)*(3*9)+(60.^2)) =65.7
t9 = sqrt((5*9)*(5*9)+(60.^2)) =69.9
t10 = sqrt((4*9)*(4*9)+(60.^2)) = 75
My code:
a = input(speed);
spd = a*3.6;
spd_1 = spd/60;
b =input(range);
for bb = 0:10
c = (sqrt(spd_1*bb).^2+(b.^2))
end
kindly share the details ,how to make a loop for t0 to t10 values and plot a graph
댓글 수: 0
채택된 답변
Birdman
2018년 3월 19일
You do not need a for loop in this case. Use vectorized code:
a=150;b=60;
spd=a*3.6;
spd_1=spd/60;
bb=[5:-1:1 0 1:5];
c=sqrt((spd_1.*bb).^2+b.^2)
댓글 수: 0
추가 답변 (1개)
KSSV
2018년 3월 19일
t0 = sqrt((5*9)*(5*9)+(60.^2))
t1 = sqrt((4*9)*(4*9)+(60.^2))
t2 = sqrt((3*9)*(3*9)+(60.^2))
t3 = sqrt((2*9)*(2*9)+(60.^2))
t4 = sqrt((1*9)*(1*9)+(60.^2))
N = 5 ;
T = zeros(N,1) ;
for i = 1:N
T(i) = sqrt((i*9)*(i*9)+(60.^2)) ;
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!