Error using imagesc and for loop

I am using the following for loop to determine the efficiency of my membrane-less electrolyzer. I am trying to variate the current,c, from 0 to 1000 mA/cm2 and the width of the cell from 0 to 5 mm. The efficiency is the the reversible potential (1.23 V) divided by the delta cell voltage
nE=Uw/(Uw+nHER+nOER+nOhm)
nHER= log10(c/ioher).*bher;
nOER=log10(c/iooer).*boer;
nOhm= I*R ( current times resistance)
I=c*Ae;
R=(-23.758.*(w).^2)+(62.769.*w)+0.0201; % resistance determined using COMSOL
ioher and ioer are constants
Ae= electrode area
w=linspace(0.01,0.5,100);
c=linspace(0.01,1,100);
Uw=1.23;%Volts
%Ae=0.0002;
ioher = (1.3).*(10.^-3); %A/cm2
iooer=(7.6).*(10.^-10); %A/cm2
boer=(43./1000); %V/decade
bher=(32./1000); %V/decade
row=(1./0.226); %cm/S
Ae=0.3005; %cm2
nOhm=zeros(length(c),length(w));
R=zeros(length(w));
I=zeros(length(c));
nHER=zeros(length(c),length(w));
nOER=zeros(length(c),length(w));
Vcell=zeros(length(c),length(w));
nE=zeros(length(c),length(w));
for i=1:length(w)
w_run=w(i);
for j=1:length(c)
c_run=c(j);
R(i)=(-23.758.*(w_run).^2)+(62.769.*w_run)+0.0201;
I(j)=c_run.*Ae;
nOhm(i,j)= I(i).*R(j); %volts
nHER (j)= log10(c_run./ioher).*bher;%Volts // Tafel Eqn
nOER (j)=log10(c_run./iooer).*boer; %Volts // Tafel Eqn
Vcell(i,j)= Uw+abs(nHER(j))+nOER(j)+nOhm(i,j);
nE(i,j)=(Uw./Vcell(i,j)).*100; % percentage
end
i;
end
figure (1)
imagesc(w.*10,c.*1000,nE)
set(gca, 'YDir','normal')
ylim([0 inf])
colorbar
colormap jet(256)
xlabel('w [mm]')
ylabel('Current density [mA cm^-2]')
Thank you so much

1 个评论

Your code does not throw an error. It produces this pretty picture:

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by