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 CenterFile Exchange에서 Foundation 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