Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammad Khan
am 26 Nov. 2022
Kommentiert: Mohammad Khan
am 27 Nov. 2022
I want to assign an array of numbers to a corresponding list name. Or in another word, I want each element of the left array to be assigned to a variable name on the right. The number of element in both arrays are the same.
I am new in Matlab. I dont know why I get this error. Any help would be very appriciated.
------------------------------------
CEST = [2022,10, 11, 2, 0, 0]
UTC = CEST-[0, 0, 0, 2, 0, 0]
[yyyy, mm, dd, hour, minute, second]= UTC
Error: line 3, Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
2 Kommentare
Stephen23
am 26 Nov. 2022
Bearbeitet: Stephen23
am 26 Nov. 2022
It looks like you expect this line:
[yyyy, mm, dd, hour, minute, second]= UTC
to perform some kind of array "unpacking" or something like that. MATLAB does not have numeric array unpacking. With some container classes you can use a comma-separated list:
You might find it beneficial to work with DATETIME objects, rather than manipulating dates "by hand" like that.
Akzeptierte Antwort
Voss
am 26 Nov. 2022
CEST = [2022,10, 11, 2, 0, 0];
UTC = CEST-[0, 0, 0, 2, 0, 0];
This is what you intend to do:
yyyy = UTC(1);
mm = UTC(2);
dd = UTC(3);
hour = UTC(4);
minute = UTC(5);
second = UTC(6);
% display the variables' values
yyyy, mm, dd, hour, minute, second
Or, to do the same thing in a way more like what you had in mind:
temp = num2cell(UTC);
[yyyy, mm, dd, hour, minute, second] = deal(temp{:})
1 Kommentar
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!