Trouble with getting table=() to work

조회 수: 10 (최근 30일)
ray brunkow
ray brunkow 2015년 9월 13일
답변: ray brunkow 2015년 9월 13일
Hello, I just started playing around with some basic text formatting with Matlab. In one set of code I had zero problems getting the table function to work as expected, yet now using the same basic format it is providing a worthless error:
Error: File: my.m Line: 97 Column: 44 The expression to the left of the equals sign is not a valid target for an assignment.
the following lines provide nice clean column matrices as is required for my table output. they are all 6x1:
Element = {'Theta';'R';'Xm';'Z';'Req';'Xeq'}
Open_Circuit = {thetaSC;Rc;Xm;'NA';'NA';'NA'}
Short_Circuit = {'NA';'NA';'NA';Zsc;XZsc;YZsc}
Low_Voltage = {'NA';RCsec;XMsec;'NA';Req_sec;Xeq_sec}
When I run them without the ; they produce the following:
Element =
'Theta'
'R'
'Xm'
'Z'
'Req'
'Xeq'
Open_Circuit =
[ 1.3134]
[1.7633e+03]
[ 534.0370]
'NA'
'NA'
'NA'
Short_Circuit =
'NA'
'NA'
'NA'
[0.5589 + 2.1231i]
[ 0.5589]
[ 2.1231]
Low_Voltage =
'NA'
[440.8333]
[133.5093]
'NA'
[ 0.1397]
[ 0.5308]
This is correct behavior for those lines of code, yet when I add the following everything blows up:
Equivalen_Circuit_through_Low-voltage_Side = table(Open_Circuit,Short_Circuit,Low_Voltage,'RowNames',Element)
Matlab provides a worthless error message from above. I see no difference between this broken code and the following fully functional code:
Element = {'R primary';'X primary';'Rc';'Xm';'R secondary';'X secondary'};
per = {'pu';'pu';'pu';'pu';'pu';'pu'};
Value = {Rp_pu;Xp_pu;Rc_pu;Xm_pu;Rs_pu;Xs_pu};
Per_Unit_Values = table(per,Value,'RowNames',Element);
This produces a nice clean table as expected:
Per_Unit_Values =
per Value
____ _________
R primary 'pu' [ 0.0100]
X primary 'pu' [ 0.0141]
Rc 'pu' [78.1250]
Xm 'pu' [ 9.3750]
R secondary 'pu' [ 0.0043]
X secondary 'pu' [ 0.0052]
So I am here asking for some assistance. The table is not required, but its so much nicer then single line responses or worse just allowing the variable to display its answer two lines lower on the screen. Very sloppy output I'd like to avoid.
Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 13일
Equivalen_Circuit_through_Low-voltage_Side = table(Open_Circuit,Short_Circuit,Low_Voltage,'RowNames',Element) '
has a subtraction on the left side of the "=". Perhaps you wanted Low_voltage instead of Low-voltage
  댓글 수: 1
Stephen23
Stephen23 2015년 9월 13일
Perhaps the documentation might be useful: "A valid variable name starts with a letter, followed by letters, digits, or underscores".

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

추가 답변 (1개)

ray brunkow
ray brunkow 2015년 9월 13일
Thank you that was a simple fix, I just was unable to see that simple typo. Many thanks.
Code works flawlessly now.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by