Insufficient number of outputs from right hand side of equal sign to satisfy assignment.

조회 수: 7(최근 30일)
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
Mohammad Khan
Mohammad Khan 2022년 11월 26일
Thanks for the explanation but still I could'nt solve the problem.

댓글을 달려면 로그인하십시오.

채택된 답변

Voss
Voss 2022년 11월 26일
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
yyyy = 2022
mm = 10
dd = 11
hour = 0
minute = 0
second = 0
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{:})
yyyy = 2022
mm = 10
dd = 11
hour = 0
minute = 0
second = 0
  댓글 수: 1
Mohammad Khan
Mohammad Khan 2022년 11월 27일
Thanks for the sugested solution. It gave me an idea and I solved my problem like this.
CEST = [2022,10, 11, 2, 0, 0];
UTC = CEST-[0, 0, 0, 2, 0, 0];
This was my function to convert Georgian Calender to Julian Calender.
function [jd,mdj] = gre2jd(yyyy,mm,dd,hour,minute,second);
Then I assigned the the above date to the entry varaible to my function like this.
[jd,mdj] = gre2jd(UTC(1),UTC(2),UTC(3),UTC(3),UTC(4),UTC(5),UTC(6));

댓글을 달려면 로그인하십시오.

추가 답변(0개)

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by