How to retrieve last entry of different array outputs for each loop?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tanya Sharma
el 28 de Sept. de 2021
Comentada: Mathieu NOE
el 30 de Sept. de 2021
I have a function returning output as arrays of different lengths.
How can I retrieve the last entry of each array at each loop step?
Say for each loop entry
for a=1:1:10
the output array is of different lengths
xinit=0:0.1:1;
solinit=(xinit,[1 1 0]);
bvp4c=sol(@ode,@bcs,solinit); %%function odes contain the values of a and for each a the output has different lengths
v=sol.y(1,11);
fprintf('%g\n',v);
Now sol.y(1,11) will give me the last entry of my solution y.
But depending on variations in 'a', the array length changes.
So how do I print each last output for each 'a'?
0 comentarios
Respuesta aceptada
Mathieu NOE
el 28 de Sept. de 2021
hello
if the solution (v) has variable length , you can do this
v=sol.y(1,:); % v is a vector of unknown length
fprintf('%g\n',v(end)); % print each last value of v
2 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!