필터 지우기
필터 지우기

Why do I get the error "Unbalanced or unexpected parenthesis or bracket?"

조회 수: 2 (최근 30일)
성주 김
성주 김 2023년 5월 1일
편집: Steven Lord 2023년 5월 1일
I wrote an electrical capacitor code for importing to the simscape component from the simulink and proceeded with the compile, and an error such as "Unbalanced or unexpected parenthesis or bracket."
The following is a rough structure of the code I used.
component mycapacitor < foundation.electrical.electrical
parameters
A[7] = {560 , 320, 6690,9400,3400,9600,6700} ;
B[7] = {1.09, 1.14, 1.57, 4.75, 2.02, 1.041, 6.00};
end
variables
vc = {value = { 0, 'V' }, priority = priority.high}; % Capacitor voltage
end
intermediates
power_dissipated = r*i^2+g*vc^2;
end
equations
assert(c>0)
assert(g>=0)
assert(isfinite(g))
assert(r>=0)
assert(isfinite(r))
for i = 1:m
v == i*A[i] + vc*B[i];
i == c*vc.der + g*vc;
end
end
[SL: Formatted code as code.]
An error occurred in A[7] and B[7] of the above code. The language is known based on the modelica code. I used most of the array methods in the modelica code, but I got the same error. What's the problem??
  댓글 수: 2
Luca Ferro
Luca Ferro 2023년 5월 1일
편집: Luca Ferro 2023년 5월 1일
I don't understand if you want help on modelica code or to convert it in matlab code
성주 김
성주 김 2023년 5월 1일
Thank you for your question. To use the simscape component block, import the ssc file and proceed with the compilation. At this time, it should be written based on the modelica code, so I think I should get help with the modelica code.

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

답변 (1개)

Walter Roberson
Walter Roberson 2023년 5월 1일
As far as I can see, Simscape uses () for indexing, not []
  댓글 수: 1
성주 김
성주 김 2023년 5월 1일
Thank you for your reply. As a result of changing to A[7] -> A(7) reflecting your advice, the same error occurred. Is there any other way?? I would appreciate it if you could give me an answer.

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

카테고리

Help CenterFile Exchange에서 Composite Components에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by