I am getting Unbalanced or unexpected parenthesis or bracket?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Jan
le 12 Juin 2018
@vamsi Teki: If you insert the code in the editor, you see, which line is causing the problem - a very useful information.
Réponse acceptée
Jan
le 12 Juin 2018
Modifié(e) : Jan
le 12 Juin 2018
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 commentaires
Plus de réponses (1)
Pawel Jastrzebski
le 12 Juin 2018
Modifié(e) : Pawel Jastrzebski
le 12 Juin 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 commentaire
Voir également
Catégories
En savoir plus sur Numbers and Precision dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!