can not get values
1 次查看(过去 30 天)
显示 更早的评论
i built this mathimaticly project of tram running simulation , but there is no error and at the same time there is no output values (all values are zero), would u please help me and diagnose the matter ?
0 个评论
采纳的回答
Daníel Freyr Hjartarson
2019-1-29
You were overwriting you calculations of a,v and s. I created matrices to save your results instead. That gives you a better overview of your timesteps. But your problem seems to be in the interpolation you are doing the first NaN is returned by the call interp1(R(:,1), R(:,2), t). It's unclear for me what you are interpolation between, could you give some more information on that?
%% Starting calculation
a_res = zeros(100,100);
v_res = zeros(100,100);
s_res = zeros(100,100);
for t = 1:100
w0 = interp1(W0(:,1), W0(:,2), v);
if interp1(R(:,1), R(:,2), t) > 0
R = interpl(R(:,1), R(:,2), t);
wR = 600*m*g/(R - 55);
else
wR = 0;
end
inc = interp1(INC(:,1), INC(:,2), s);
w_inc = inc*m*g;
w_sum = w0 + w_inc + wR;
if (v < vmax) && (s < Sstop - Sbraking)
F = interp1(TE(:,1), TE(:,2), v);
elseif (v >= vmax) && (s < Sstop - Sbraking)
F = w_sum;
elseif s >= Sstop - Sbraking
F = 0;
end
a = (F - w_sum)/m*(1 + K);
v = v + a;
s = s + a*t;
i = interp1(I(:,1), I(:,2), v);
P = U*i;
efficiency = F*v / P ;
E = P*t;
%saving the results of calculation
a_res(:,t) = a;
v_res(:,t) = v;
s_res(:,t) = s;
end
0 个评论
更多回答(1 个)
Mark Sherstan
2019-1-29
Your data set and interplation dont line up. The R variable you define is:
R =
379 24
1000 56
1180 110
1300 72
2360 1170
2990 328
6200 154
6320 192
9149 283
Looking at the first couple loops t will be 1, 2, 3, ...
interp1(R(:,1),R(:,2),t)
t has nothing to interpolate to. It is not bounded by any values and will output "nan" which forces your if statment:
if interp1(R(:,1),R(:,2),t)>0
R=interpl(R(:,1),R(:,2),t);
wR=600*m*g/(R-55);
else
wR=0;
end
To output a zero answer. Try fixing up your data sets and solve the first couple itterations by hand to make sure everything makes sense.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!