"Assignment between unlike types is not allowed" in STRUCTURES
Afficher commentaires plus anciens
Hello,
Please suppose the following matrices and structure:
X1 = zeros(1, 4);
X2 = zeros(2, 4);
X3 = zeros(3, 4);
AA.SM = []; p = repmat(AA, 3, 1); % 3 is not fixed
PN.SM = p; PN = repmat(PN, 100, 1); % 100 is not fixed
When I want to assign X1, X2 and X3 to PN, I receive an error stating that "Assignment between unlike types is not allowed."
PN(1).SM(1) = X1;
PN(1).SM(2) = X2;
PN(1).SM(3) = X3;
I have also tried "setfield" function, but it does not work.
Could you please help me to resolve this difficulty?
Best regards,
AM
Réponse acceptée
Plus de réponses (1)
KSSV
le 6 Juin 2019
You amy try something like this:
PN = struct ;
PN(1).SM(1).X = rand(10,1) ;
PN(1).SM(2).X = rand(20,1) ;
PN(1).SM(3).X = rand(30,1) ;
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!