"Assignment between unlike types is not allowed" in STRUCTURES
Show older comments
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
Accepted Answer
More Answers (1)
KSSV
on 6 Jun 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) ;
Categories
Find more on Structures in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!