Use index in anonymous function
Mostrar comentarios más antiguos
Hi guys
can i include index in anonymous function for example something like this where T is matrix element. And can i call it in for loop for example:
syms T n m
delta_x=(1/50);delta_t=0.001;
x=0:delta_x:1;
t=0:delta_t:0.25;
Lamda=((delta_t)/((delta_x)^2));
n=1:length(t);m=2:length(x);k=1;
Tem=@(T,n,m)((-Lamda*T(n+1,m-1))+(2*(1+Lamda)*T(n+1,m))-(Lamda*T(n+1,m+1)))....
-((Lamda*T(n,m-1)) +(2*(1-Lamda)*T(n,m)) +(Lamda*T(n,m+1)));
for n=1:length(t)-1
for m=2:length(x)
if n==1
T(n,m)=250;
elseif m==1 && n>=2
T(n,m)=350;
else
Temp{1}=Tem(T,n,m); % I want to generate several equations from thie line
end
end
end
Best Regards,
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!