A car laps a racetrack in 90s. The speed of the car at each 6 second interval is determined using a radar gun and is given from the beginning of the lap, in m/s.
7 ビュー (過去 30 日間)
古いコメントを表示
Length of track is estimated by ? = 2ℎ/45 ∑ n(i=0) 7*?(?4?−4) + 32*?(?4?−3) + 12*?(?4?−2) + 32*?(?4?−1) + 7*?(?4?) This is my code:
function [ ] = Q2( ~ )
k=[0,1,2,3,4,5,6,7,8,9,10,11,12];
t=[0,6,12,18,24,30,36,42,48,54,60,66,72];
s=[0,134,148,156,147,133,121,99,85,78,89,104,92];
L=0;
i=1;
n=(t(13)-t(1))./4*6;
while(i<=n)
L=L+(7*s(i)-4)+(32*s(4*i)-3)+(12*s(4*i)-2)+(32*s(4*i)-1)+(7*s(4*i));
i=i+1;
end
L=L*(2*6./45);
disp('L');
end
But i end up getting result as index exceeds number of array elements. Why?
0 件のコメント
採用された回答
Rik
2018 年 9 月 23 日
Two changes (also, k is unused):
function Q2(~)
k=[0,1,2,3,4,5,6,7,8,9,10,11,12];
t=[0,6,12,18,24,30,36,42,48,54,60,66,72];
s=[0,134,148,156,147,133,121,99,85,78,89,104,92];
L=0;
i=1;
n=(t(13)-t(1))/(4*6);%changed from ./4*6
while(i<=n)
L=L+(7*s(i)-4)+(32*s(4*i)-3)+(12*s(4*i)-2)+(32*s(4*i)-1)+(7*s(4*i));
i=i+1;
end
L=L*(2*6./45);
disp(L);%changed from 'L'
end
1 件のコメント
Rik
2018 年 9 月 27 日
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!