I am getting Unbalanced or unexpected parenthesis or bracket?

조회 수: 7 (최근 30일)
vamsi Teki
vamsi Teki 2018년 6월 12일
댓글: Jan 2018년 6월 12일
Actually i have written code in mask parameter in initialization and while i am applying i am getting error like unbalance or unexpected parenthesis or bracket so can please help me out of this problem...... i am using matlab 2014 version.... here is the code...
if PlotVI_Module
assignin('base', 'Voc', Voc);
assignin('base', 'Isc', Isc);
assignin('base', 'Rs', Rs);
assignin('base', 'Rp', Rp);
assignin('base', 'Isat', Isat);
assignin('base', 'Vt', Vt);
if PlotVI_Module,
F1 = figure('Name', 'IV and PV characteristics of a Module at 25 deg.c');
end
load_system('PV_Model_Param');
for ksun=1:-0.25:0.25
assignin('base', 'Iph', Iph*ksun);
sim('PV_Model_Param');
n=find(I_PV>=1);
I_PV=I_PV(n);
P_PV=V_PV.*I_PV;
if PlotVI_Module
figure(F1);
subplot(211)
if ksun==1
plot(V_PV, I_PV, 'b' (0 Vmp Voc), (Isc Imp 0), 'ro')
text(Voc/15, Isc*1.1, '1 Kw/m^2')
hold on
grid
else
plot(V_PV, I_PV, '--m')
text(Voc/15, Isc*(ksun+0.1), sprintf('%g Kw/m^2', ksun))
end
subplot(212)
if ksun==1
plot(V_PV, P_PV, 'b', (0 Vmp Voc), (0 Imp*Vmp 0), 'ro')
text(Vmp*1.02, Vmp*Imp, '1 Kw/m^2')
hold on
grid
else
n=find(P_PV==max(P_PV));
plot(V_PV, P_PV, '--m', V_PV(n), P_PV(n), 'mo')
text(Vmp*1.02, Vmp*Imp*ksun, sprintf('%g Kw/m^2', ksun))
end
subplot(211)
ylabel('Current (A)')
xlabel('Voltage (V)')
title('PV_Module')
axis_xy=axis;
axis_xy(4)=Isc*1.2;
axis(axis_xy);
subplot(212)
ylabel('Power (W)')
xlabel('Voltage (V)')
axis_xy=axis;
axis_xy(4)=Vmp*Imp*1.2;
axis(axis_xy);
set_param(BlockName,'PlotVI_Module', 'off')
end
end
end
  댓글 수: 6
Jan
Jan 2018년 6월 12일
@vamsi Teki: If you insert the code in the editor, you see, which line is causing the problem - a very useful information.
vamsi Teki
vamsi Teki 2018년 6월 12일
ok sir sure next time on-wards when i use code for my matlab file i will check like this only if i get any errors.... thank you so much for sparing time for me

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

채택된 답변

Jan
Jan 2018년 6월 12일
편집: Jan 2018년 6월 12일
This is no valid Matlab syntax:
plot(V_PV, I_PV, 'b' (0 Vmp Voc), (Isc Imp 0), 'ro')
% ^^^^^^^^^^^ ^^^^^^^^^^^
and
plot(V_PV, P_PV, 'b', (0 Vmp Voc), (0 Imp*Vmp 0), 'ro')
% ^^^^^^^^^^^ ^^^^^^^^^^^^^
What is the purpose of these lines? Perhaps you want to replace the round parentheses by square brackets for a horizontal concatenation, and insert a comma in the first case?
plot(V_PV, I_PV, 'b', [0 Vmp Voc], [Isc Imp 0], 'ro')
plot(V_PV, P_PV, 'b', [0 Vmp Voc], [0 Imp*Vmp 0], 'ro')

추가 답변 (1개)

Pawel Jastrzebski
Pawel Jastrzebski 2018년 6월 12일
편집: Pawel Jastrzebski 2018년 6월 12일
Line 1: get rid of the comma:
if PlotVI_Module
Line 15 and 25: change round brackets to square ones and you had a one missing comma:
plot(V_PV, I_PV, 'b', [0 Vmp Voc], [Isc Imp 0], 'ro')
Additional remark: if you keep multiple data sets within one plot function, it might be useful to separate them by line using ellipsis (...) - this way the code is easier to read, i.e.
% plot(x,y, color settings)
plot(...
V_PV , I_PV , 'b', ...
[0 Vmp Voc], [Isc Imp 0], 'ro')
Last line: it seems that you have one end too many - select all of the code and press Ctrl+I to align the code properly for better clarity.
  댓글 수: 1
Jan
Jan 2018년 6월 12일
+1. Separating the data in a multi-input plot command is nice.

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

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by