Borrar filtros
Borrar filtros

How can I index variables inside loops????

1 visualización (últimos 30 días)
ahmad mahmoodi
ahmad mahmoodi el 14 de Oct. de 2018
Hello all,
How can I simply write a code like this:
function dT=Mesal(T,t)
n=100; dT=zeros(n,1);
for i=1:n
if i==1
dT(i)=T(i);
elseif i==n
dT(i)=T(i-1);
else
dT(i)=T(i+1);
end
end
Thank you in advance.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!