how can i name my output and display it?

조회 수: 2 (최근 30일)
arian hoseini
arian hoseini 2022년 1월 11일
댓글: Steven Lord 2022년 1월 11일
L =[1 2 0.1 0.2 0.02
1 4 0.05 0.2 0.02
1 5 0.08 0.3 0.03
2 3 0.05 0.25 0.03
2 4 0.05 0.1 0.01
2 5 0.1 0.3 0.02
2 6 0.07 0.2 0.025
3 5 0.12 0.26 0.025
3 6 0.02 0.1 0.01
4 5 0.2 0.4 0.04
5 6 0.1 0.3 0.03]
ln = L(:,1);
rn = L(:,2);
Pt=[ 25.33, 41.57, 33.1, 1.854, 32.48, 16.22, 24.78, 16.93, 44.92, 4.045, 0.2999]
Pt = 1×11
25.3300 41.5700 33.1000 1.8540 32.4800 16.2200 24.7800 16.9300 44.9200 4.0450 0.2999
so i want to use table(if there is any other way thatn using table please tell me) and i want 3 column (FromBus,ToBus,P)
P is my Pt
FromBus is ln
ToBus is rn
it should be like this
FromBus ToBus P
1 2 25.33
1 4 41.57
1 5 33.1
2 3 1.854
2 4 32.48
2 5 16.22
2 6 24.78
3 5 16.93
3 6 44.92
4 5 4.045
5 6 0.2999
  댓글 수: 3
arian hoseini
arian hoseini 2022년 1월 11일
T = table(ln,rn,Pt,'VariableNames',{'From Bus','To Bus','P',});
i dont know if im doing it right
Error using matlab.internal.tableUtils.makeValidName (line 39)
'From Bus' is not a valid variable name.
Error in matlab.internal.table.tableVarNamesDim (line 37)
matlab.internal.tableUtils.makeValidName(labels,'varnamesError');
Error in table (line 256)
t.varDim = matlab.internal.table.tableVarNamesDim(numVars,varnames); % error if invalid,
duplicate, or empty
Error in DCPowerFlow (line 92)
T = table([ln,rn,Pt],'VariableNames',{'From Bus','To Bus','P',});
>>
Steven Lord
Steven Lord 2022년 1월 11일
Prior to release R2019b table variable names were required to be valid MATLAB identifiers. Release R2019b relaxes this restriction, allowing the use of spaces (among other symbols.)

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

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2022년 1월 11일
편집: KALYAN ACHARJYA 2022년 1월 11일
#Check Pt array size? Use ; for column vector or use traspose in the table data.
T=table(ln,rn,Pt','VariableNames',{'From Bus','To Bus','P',})
  댓글 수: 5
KALYAN ACHARJYA
KALYAN ACHARJYA 2022년 1월 11일
편집: KALYAN ACHARJYA 2022년 1월 11일
You may need to convert the symbolic values to double?
Try
T=table(ln,rn,double(Pt)','VariableNames',{'From Bus','To Bus','P',})
arian hoseini
arian hoseini 2022년 1월 11일
thank u sir...best wishes for u.

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

추가 답변 (0개)

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by