can not get values

1 回表示 (過去 30 日間)
Riyadh Salim
Riyadh Salim 2019 年 1 月 29 日
回答済み: Mark Sherstan 2019 年 1 月 29 日
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 ?

採用された回答

Daníel Freyr Hjartarson
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

その他の回答 (1 件)

Mark Sherstan
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.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by