How can i solve the vertcat error.

2 Ansichten (letzte 30 Tage)
Onkar Hedalkar
Onkar Hedalkar am 19 Mär. 2018
Bearbeitet: Jan am 20 Mär. 2018
Changing_Parameter = '(Gc=STC Tc=Variable)';
DataSheet_Values = ...
[Model;Area;Pmpp_stc;Voc_stc;Isc_stc;Impp_stc;Vmpp_stc;' ';Ns;Ki;Kv;Tc;Gc;' ';...
a;a1;a2;Pe;' ';D1Rs;D1Rp;D2Rs;D2Rp;Eg;];
xlswrite(Sim_Results,DataSheet_Values,'Tvar','C3')
tempvec = simout_D1_Tvar(1,10:13);
VOC = zeros(1,4);
ISC = zeros(1,4);
Pmpp = zeros(1,4);
Impp = zeros(1,4);
Vmpp = zeros(1,4);
FF = zeros(1,4);
ETA = zeros(1,4);
i = 2;
j = 1;
For Tc = tempVec
P = simout_D1_Tvar(:,(i+4));
I = simout_D1_Tvar(:,1);
V = simout_D1_Tvar(:,1);
[Izero,row] = min(abs(I(:)));
Voc = V(row);
VOC(1,j) = Voc;
Isc = i(1);
ISC(1,j) = Isc;
[Pmax,roww]=max(P);
Pmpp(1,j) = Pmax;
Imax = I(roww);
Impp(1,j) = Imax;
Vmax = V(row);
Vmpp(1,j) = Vmax;
FFn = (Vmax*Imax)/(Voc*Isc);
FF(1,j) = FFn;
Pmppp_stc = 1000*Area;
Eta = ((Voc*Isc*FFn)/Pmpp_stc)*100;
ETA(1,j) = Eta;
i=i+1;
j=j+1;
P_array = simout_D1_Tvar(:,6,9);
I_array = simout_D1_Tvar(:,2,5);
V_array = simout_D1_Tvar(:,1);
PY = max(P_array);
IY = max(I_array);
PYmax = max(PY)*1.1;
IYmax = max(IY)*1.1;
VXmax = max(VOC)*1.1;
figure
plot(V_array, P_array,'LineWidth',1);
axis([0 VXmax 0 PYmax]);
grid on;
title(['Single Diode VP Plot (Gc=STC Tc=Variable)', Model]);
xlabel('Output voltage, V');
ylabel('Output power, W');
legend( ...
['T = ',num2str(tempVec(1,1),'%0f'),'c;','Pmpp = ',numstr(Pmpp(1,1),'%.2f'),'W'], ...
['T = ',num2str(tempVec(1,2),'%0f'),'c;','Pmpp = ',numstr(Pmpp(1,2),'%.2f'),'W'], ...
['T = ',num2str(tempVec(1,3),'%0f'),'c;','Pmpp = ',numstr(Pmpp(1,3),'%.2f'),'W'], ...
['T = ',num2str(tempVec(1,4),'%0f'),'c;','Pmpp = ',numstr(Pmpp(1,4),'%.2f'),'W'], ...
'Location','NorthWest');
figure
plot(V_array, I_array,'LineWidth',1);
axis([0 VXmax 0 IYmax]);
grid on;
title(['Single Diode VI Plot (Gc=STC Tc=Variable)'; Model]);
xlabel('Output voltage, V');
ylabel('Output Current, A');
legend( ...
['Tc = ',num2str(tempVec(1,1),'%0f'),'c;','Isc = ',num2str(Isc(1),'%.2f'),'A',' Voc = ',num2str(VOC(1),'%.2f'),'V;'], ...
['Tc = ',num2str(tempVec(1,2),'%0f'),'c;','Isc = ',num2str(Isc(2),'%.2f'),'A',' Voc = ',num2str(VOC(2),'%.2f'),'V;'], ...
['Tc = ',num2str(tempVec(1,3),'%0f'),'c;','Isc = ',num2str(Isc(3),'%.2f'),'A',' Voc = ',num2str(VOC(3),'%.2f'),'V;'], ...
['Tc = ',num2str(tempVec(1,4),'%0f'),'c;','Isc = ',num2str(Isc(4),'%.2f'),'A',' Voc = ',num2str(VOC(4),'%.2f'),'V;'], ...
'Location','NorthWest');
figure
EtaYmax = max(Eta)*1.1;
TXmax = max(tempVec)+10;
TXmin = min(tempVec)-10;
stem(tempVec(1),ETA(1),'LineWidth',1); hold on
stem(tempVec(2),ETA(2),'LineWidth',1); hold on
stem(tempVec(3),ETA(3),'LineWidth',1); hold on
stem(tempVec(4),ETA(4),'LineWidth',1); hold on
axis([TXmin TXmax 0 EtaYmax])
grid on
title(['Single Diode Efficiency (Gc=STC Tc=Variable)';Model]);
xlabel('Temperature(Tc)');
ylabel('Efficiency (Eta)')
legend( ...
['Eta = ',num2str(ETA(1),'%.2f'),' %',' %Tc = ',num2str(tempVec(1,1),'%.0f'),'C'], ...
['Eta = ',num2str(ETA(2),'%.2f'),' %',' %Tc = ',num2str(tempVec(1,2),'%.0f'),'C'], ...
['Eta = ',num2str(ETA(3),'%.2f'),' %',' %Tc = ',num2str(tempVec(1,3),'%.0f'),'C'], ...
['Eta = ',num2str(ETA(4),'%.2f'),' %',' %Tc = ',num2str(tempVec(1,4),'%.0f'),'C'], ...
'Location','NorthEast');
Results1 = ...
[Changing_Parameter;tempVec(1,1);tempVec(1,2);TempVec(1,3);tempVec(1,4);];
Results2 = [Pmpp(1,1);Pmpp(1,2);Pmpp(1,3);Pmpp(1,4);];
Results3 = [ETA(1);ETA(2);ETA(3);ETA(4);];
Results4 = [FF(1,1);FF(1,2);FF(1,3);FF(1,4);];
Results5 = [Vmpp(1,1);Vmpp(1,2);Vmpp(1,3);Vmpp(1,4);];
Results6 = [Impp(1,1);Impp(1,2);Impp(1,3);Impp(1,4);];
Results7 = [ISC(1,1);ISC(1,2);ISC(1,3);ISC(1,4);];
Results8 = [VOC(1,1);VOC(1,2);VOC(1,3);VOC(1,4);];
xlswrite(Sim_Results,Results1,'Tvar','E3');
xlswrite(Sim_Results,Results2,'Tvar','F4');
xlswrite(Sim_Results,Results3,'Tvar','G4');
xlswrite(Sim_Results,Results4,'Tvar','H4');
xlswrite(Sim_Results,Results5,'Tvar','I4');
xlswrite(Sim_Results,Results6,'Tvar','J3');
xlswrite(Sim_Results,Results7,'Tvar','K4');
xlswrite(Sim_Results,Results8,'Tvar','L4');
% End of code
when i run this program. error comes like '"
>> script4
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in script4 (line 4) [Model;Area;Pmpp_stc;Voc_stc;Isc_stc;Impp_stc;Vmpp_stc;' ';Ns;Ki;Kv;Tc;Gc;' ';...

Antworten (2)

Rik
Rik am 19 Mär. 2018
If you want to write something to 1 cell in an Excel file, you probably mean to concatenate to a row instead of column-wise.
DataSheet_Values=...
[Model,Area,Pmpp_stc,Voc_stc,Isc_stc,Impp_stc,Vmpp_stc,' ',Ns,Ki,Kv,Tc,Gc,' ',...
a,a1,a2,Pe,' ',D1Rs,D1Rp,D2Rs,D2Rp,Eg];
  1 Kommentar
Rik
Rik am 19 Mär. 2018
Sent by email:
sir but now how i can change the code. can you send modified code plz
You don't use the variable elsewhere in your code, so this is enough modification to solve this error. You didn't explain what you want to do, or what anything means. If you wrote this code yourself you should understand what it does, if not, contact the person from whom you got it.
A last note: sending an e-mail is generally less effective than posting a comment, as anybody can reply to a comment, but only I can reply to my e-mail.

Melden Sie sich an, um zu kommentieren.


Jan
Jan am 20 Mär. 2018
Bearbeitet: Jan am 20 Mär. 2018
I guess, that you want a cell array instead (curly braces):
DataSheet_Values = {Model, Area, Pmpp_stc, Voc_stc, Isc_stc, ...
Impp_stc, Vmpp_stc, ' ', Ns, Ki, Kv, Tc, Gc, ' ', ...
a, a1, a2, Pe, ' ', D1Rs, D1Rp, D2Rs, D2Rp, Eg};
The error is caused by the concatenation of strings of different lengths:
C = ['123'; '45']
This cannot work, because a matrix must be rectangular - all rows must have the same length. To store objects of different type or size, use a cell array.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by