Error, matrix dimension must agree

1 次查看(过去 30 天)
Voc = app.LinetolinevoltageVocEditField.Value;
Ioc = app.LinetolinecurrentAocEditField.Value;
Woc = app.ThreephasepowerkWocEditField.Value/3;
Vsc = app.LinetolinevoltageVscEditField.Value;
Isc = app.LinetolinecurrentAscEditField.Value;
Wsc = app.ThreephasepowerkWscEditField.Value/3;
Vp = app.PrimarysidelinevoltageVEditField.Value;
Vs = app.SecondorysidelinevoltageVEditField.Value;
if(app.StepdowntransformerButton.Value)
a = Vp ./ Vs;
if(app.DeltastarconnectionButton.Value)
Voc = Voc/sqrt(3);
pfoc = Woc/(Voc*Ioc);
if(pfoc>=1)
app.errorTextArea.Value = 'Error! Power factor is more than 1!';
else
Ro = Voc/(Ioc*pfoc);
app.RcTextArea.Value = num2str(Ro);
sineoc = sin(acos(pfoc));
Xm = Voc/(Ioc*sineoc);
app.XmTextArea.Value = num2str(Xm);
Isc = Isc/sqrt(3);
pfsc = Wsc/(Vsc*Isc);
if(pfsc>=1)
app.errorTextArea.Value = 'Error! Power factor is more than 1!';
else
Req = Wsc/(Isc*Isc);
Req = Req/(a*a);
app.ReqTextArea.Value = num2str(Req);
Zeq = Vsc/Isc;
Zeq = Zeq/(a*a);
Xeq = sqrt((Zeq*Zeq)-(Req*Req));
app.XeqTextArea.Value = num2str(Xeq);
end
end
I created 2 edit fields in app designer to allow user to input values into it and the program will calculate the a of it, but for the line a = Vp ./ Vs, it keeps showing matrix dimension must agree and I am running out of idea what should I do since I am still new to Matlab, any kind advices all comments will be appreciated, thanks and sorry for wasting your time!

采纳的回答

Sampath Rachumallu
Sampath Rachumallu 2020-4-27
Here Vp ,Vs are of class 'char' and cannot be divided. So you have to convert them to integer format for division.Try
a = str2num(Vp) ./ str2num(Vs);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dimensionality Reduction and Feature Extraction 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by