how can i assign elements of a numeric matrix to variable matrix
29 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
bizzybee in
am 27 Aug. 2015
Kommentiert: Star Strider
am 29 Aug. 2015
let i have a matrix a=[2,3,4,4,5] and i have to store it in a variable matrix s=[z,x,c,v,b] such that z=2,x=3,c=4 and so on..
2 Kommentare
James Tursa
am 27 Aug. 2015
Can you be more explicit in your question? From what you have written, I would have just suggested:
s = a;
But I suspect that this isn't what you are asking. Are you trying to deal the elements of "a" into separate variables?
Akzeptierte Antwort
Star Strider
am 27 Aug. 2015
The most efficient would seem to me to be s=a, but if you want to define the variables in the interim, this works (in the most recent MATLAB releases):
a=[2,3,4,4,5];
ac = mat2cell(a, 1, ones(1,5));
[z,x,c,v,b] = ac{:};
s=[z,x,c,v,b];
2 Kommentare
Star Strider
am 29 Aug. 2015
My pleasure.
Use the deal function. However you have to enter the values manually:
[a,s,d,f,g] = deal(1,2,5,6,3);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!