Effacer les filtres
Effacer les filtres

can not get values

1 vue (au cours des 30 derniers jours)
Riyadh Salim
Riyadh Salim le 29 Jan 2019
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 ?

Réponse acceptée

Daníel Freyr Hjartarson
Daníel Freyr Hjartarson le 29 Jan 2019
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

Plus de réponses (1)

Mark Sherstan
Mark Sherstan le 29 Jan 2019
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.

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by