Invalid expression, check for mismatched delimiters. Trying to form a matrix using brackets.

6 ビュー (過去 30 日間)
I keep getting the error message: >> abc2sc
File: abc2sc.m Line: 21 Column: 28
Invalid expression. When calling a function or indexing a variable, use
parentheses. Otherwise, check for mismatched delimiters.
Here is my preliminary code.
function [symcomp] = abc2sc(fabc)
rankfabc=length(fabc(1,:));
if rankfabc == 2
mag=fabc(:,1); ang=pi/180*fabc(:,2);
fabcr=mag.(cos(ang)+jsin(ang));
elseif rankfabc ==1
fabcr=fabc;
else
fprintf('\n Three phasors must be expressed in a one column array in rectangular complex form \n')
fprintf(' or in a two column array in polar form, with 1st column magnitude & 2nd column \n')
fprintf(' phase angle in degree. \n')
return, end
a=cos(2*pi/3)+jsin(2*pi/3);
A = [1 1 1; 1 a^2 a; 1 a a^2];
fa012=inv(A)*fabcr;
symcomp= fa012;
%scpolar = [abs(fa012) 180/piangle(fa012)];
%fprintf(' \n Symmetrical components \n')
%fprintf(' Magnitude Angle Deg.\n')
%disp(scpolar)
fabc0=fa012(1) [ 1; 1; 1 ];
fabc1=fa012(2) [ 1; a^2; a ];
fabc2=fa012(3) [ 1; a; a^2 ];
end

採用された回答

Jan
Jan 2022 年 5 月 9 日
編集済み: Jan 2022 年 5 月 9 日
What is the meaning of this line:
fabcr=mag.(cos(ang)+jsin(ang));
This treats "mag" as a struct and tries to interprete "cos(ang)+jsin(ang)" as field name. What is "jsin"? Maybe you mean:
fabcr = mag .* (cos(ang) + 1j * sin(ang));
The error appears in these lines, I guess (by the way, if you post the complete error message, the readers would see, which line is failing):
fabc0=fa012(1) [ 1; 1; 1 ];
fabc1=fa012(2) [ 1; a^2; a ];
fabc2=fa012(3) [ 1; a; a^2 ];
What is the purpose of these lines? Did you forget some * characters for a multiplication? The output fabc0/1/2 is not used anywhere, so whay not simply omitting these lines?
This looks suspicious also:
a=cos(2*pi/3)+jsin(2*pi/3);
Did you really create a function called jsin()?
By the way, prefer the backslash operator instead of calling inv(). See: inv

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFoundation and Custom Domains についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by