Trying to Plot Temperature with Current Density

Hello,
I am trying to plot temperature with current denstiy. However, I get the "vectors must be the same length" error.
This is the code:
clear all
clc
close all
J0ref=2e-7; % Saturation current density mA/cm2
Rs=0.001; % Series resistance k ohm cm2
Rp=1000; % Parallel resistance k ohm cm2
n= 1.5; % Diode ideality factor
Jsc=30; % Short circuit current density in mA/cm2
k=1.38e-23; % Boltzmann constant
Tref= 300 ; % Absolute Temperature
q= 1.6e-19; % Electric charge
Eg=1.12; % Band gap of Silicon
Vx=linspace(-1,1,200);
TT=[300 350 400];
for i=1:length(TT)
Vt=k*TT(i)/q; % Thermal voltage
J0(i)=(J0ref*(TT(i)/Tref)^(3/n))*exp(-q*Eg/(n*k)*(1/TT(i)-1/Tref));
J=J0(i)*(exp(Vx/(n*Vt))-1)+Vx/Rp-Jsc;
V=Vx+J.*Rs;
before=V(find(J<0)); after= V(find(J>0));
Voc(i)=(before(end)+after(1))/2;
Power=-J.*V;
maxpos=find(Power==max(Power));
Jm=J(maxpos);
Vm=V(maxpos);
DATA=[V' , J' , Power'];
FF(i)=-Jm*Vm/(Jsc*Voc(i));
eta(i)=FF(i)*Jsc*Voc(i)/100;
h1=figure
set(h1,'name','JV Special Topics','numbertitle','on')
set(gcf,'DefaultAxesBox','on'),
set(gcf,'DefaultAxesLineWidth',2) ,
set(0,'DefaultAxesFontSize',14),
plot(TT,J);
end
What do I do to make them the same length? thank you.

12 件のコメント

darova
darova 2019 年 10 月 6 日
Can you please show the image you expect to see?
wonder_H15
wonder_H15 2019 年 10 月 6 日
Plott.png
darova
darova 2019 年 10 月 6 日
You only have 3 values for temperature
darova
darova 2019 年 10 月 6 日
Maybe spline?
wonder_H15
wonder_H15 2019 年 10 月 6 日
How do I make the temp values equal to have a proper plot?
darova
darova 2019 年 10 月 6 日
Maybe something like that
Tx = spline(TT,-1:1, linspace(TT(1),TT(end),200) )
plot(Tx,J);
wonder_H15
wonder_H15 2019 年 10 月 11 日
Still getting an error :( where should I put this statement?
wonder_H15
wonder_H15 2019 年 10 月 11 日
error.png
wonder_H15
wonder_H15 2019 年 10 月 11 日
I think it worked. Thank you!
wonder_H15
wonder_H15 2019 年 10 月 11 日
I have the same "vectors must ve the same legnth" error when trying to plot the temprature with fill factor. (the result should be kind of similar to the current plot)
clear all
clc
close all
J0ref=2e-7; % Saturation current density mA/cm2
Rs=0.001; % Series resistance k ohm cm2
Rp=1000; % Parallel resistance k ohm cm2
n= 1.5; % Diode ideality factor
Jsc=30; % Short circuit current density in mA/cm2
k=1.38e-23; % Boltzmann constant
Tref= 300 ; % Absolute Temperature
q= 1.6e-19; % Electric charge
Eg=1.12; % Band gap of Silicon
Vx=linspace(-1,1,200);
TT=[300 350 400];
for i=1:length(TT)
Vt=k*TT(i)/q; % Thermal voltage
J0(i)=(J0ref*(TT(i)/Tref)^(3/n))*exp(-q*Eg/(n*k)*(1/TT(i)-1/Tref));
J=J0(i)*(exp(Vx/(n*Vt))-1)+Vx/Rp-Jsc;
V=Vx+J.*Rs;
before=V(find(J<0)); after= V(find(J>0));
Voc(i)=(before(end)+after(1))/2;
Power=-J.*V;
maxpos=find(Power==max(Power));
Jm=J(maxpos);
Vm=V(maxpos);
DATA=[V' , J' , Power'];
FF(i)=-Jm*Vm/(Jsc*Voc(i));
eta(i)=FF(i)*Jsc*Voc(i)/100;
h1=figure
set(h1,'name','JV Special Topics','numbertitle','on')
set(gcf,'DefaultAxesBox','on'),
set(gcf,'DefaultAxesLineWidth',2) ,
set(0,'DefaultAxesFontSize',14),
Tx=spline(TT,-1:1, linspace(TT(1),TT(end),200));
F1=spline(FF,-1:1, linespace(FF(1),FF(end),200));
plot(Tx,F1);
end
darova
darova 2019 年 10 月 11 日
Put it outside the for loop
Tx=spline(-1:1,TT, linspace(-1,1,200) );
F1=spline(-1:1,FF, linspace(-1,1,200) );
plot(Tx,F1);
hold on
plot(TT,FF,'or')
hold off
And please use special button for code inserting
CODE_INSER.PNG
wonder_H15
wonder_H15 2019 年 10 月 11 日
It worked, thanks!
Also will do!

サインインしてコメントする。

 採用された回答

Srivardhan Gadila
Srivardhan Gadila 2019 年 10 月 10 日

0 投票

You may use Interpolation to increase the number of elements in the "TT" to match the number of elements in the "J".

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by