Assigning Function Name with "for" loop

Hello all,
I have a 3x3x3 matrix and i want to seperate each of this matrix with a different name.
So that i tried to use the funciton given below but i got the error "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side".
In the function psi11 is 3x3x3 matrix. How can i assign variable name with for loop?
I want to name all new functions as psi11(k).
for k=1:7
strcat('psi11',num2str(k)) = squeeze(psi11(:,k,:))
end

 Respuesta aceptada

Steven Lord
Steven Lord el 17 de Feb. de 2022

0 votos

Can you define variables this way? Yes.
Should you do this? The general consensus is no. See that Answers post for an explanation and alternatives.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 17 de Feb. de 2022

Comentada:

el 22 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by