MATLAB Answers

0

I am getting Unbalanced or unexpected parenthesis or bracket?

Asked by vamsi Teki on 12 Jun 2018
Latest activity Commented on by Jan
on 12 Jun 2018
Accepted Answer by Jan
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 Comments

thankq so much sir.... i have found my mistake...... thanks a lot for helping me
@vamsi Teki: If you insert the code in the editor, you see, which line is causing the problem - a very useful information.
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

Sign in to comment.

2 Answers

Answer by Jan
on 12 Jun 2018
Edited by Jan
on 12 Jun 2018
 Accepted Answer

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')

  0 Comments

Sign in to comment.


Answer by Pawel Jastrzebski on 12 Jun 2018
Edited by Pawel Jastrzebski on 12 Jun 2018

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 Comment

+1. Separating the data in a multi-input plot command is nice.

Sign in to comment.