Trouble with getting table=() to work
10 views (last 30 days)
Show older comments
ray brunkow
on 13 Sep 2015
Answered: ray brunkow
on 13 Sep 2015
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.
0 Comments
Accepted Answer
Walter Roberson
on 13 Sep 2015
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 Comment
Stephen23
on 13 Sep 2015
Perhaps the documentation might be useful: "A valid variable name starts with a letter, followed by letters, digits, or underscores".
More Answers (1)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!