I am getting Unbalanced or unexpected parenthesis or bracket?

5 ビュー (過去 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 Center および File ExchangeNumbers and Precision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by