for loop to use iteration and time
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello all,
I'm quite new user of Matlab.
My question is;
T_pu=ones(iter,1)*293;
T_pu_time=ones((total_t/delta_t)+1,1)*293;
delta_t=1;
total_t=36000;
iter=5;
for t=1:delta_t:total_t
for i=1:iter
x_tpu(i)=(T_e-T_pu(i))/(2));
y_tpu(i)=(T_x-T_pu(i))/(5);
T_pu(i+1)= T_pu(i)+(x_tpu(i)+y_tpu(i)))*(t/2);
if i==iter
T_pu(iter)=T_pu_time(t);
end
end
end
Shortly, I want to start from time=1 and T_pu with iteration (5 times), 5th iteration is equal of my first T_pu_time(t) matrix element, then it will continue with t=2 and 5 iteration .....
Can you please help me or share with me any example how can I solve this issue?
2 comentarios
dpb
el 24 de En. de 2021
Not clear what you're trying to do, sorry...
T_pu=ones(iter,1)*293;
T_pu_time=ones((total_t/delta_t)+1,1)*293;
delta_t=1;
total_t=36000;
iter=5;
in the above, however, you used iter to preallocate two arrays, but didn't define it until afterwards...so whatever iter was the last time you ran the code before would have just been the left over value.
What's the *293 intended to do in those two statements? Why would you preallocate arrays containing the value 293 which is what that does?
Respuestas (1)
Gaurav Garg
el 27 de En. de 2021
Hi Murat,
In order to assign 5th element of T_pu to 1st element of T_pu_time, 10th element of T_pu == 2nd element of T_pu_time and so on..., you can follow the code segment given below -
for i=1:n
T_pu_time(i) = T_pu(i*5);
end
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!