Invalid expression, check for mismatched delimiters. Trying to form a matrix using brackets.
2 次查看(过去 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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!