clc
%clear all
close all
G=1000;
R=0.372;
Rs=0.2;
lamda=300*10^(-9);
I=0.01;
h=6.626*10^(-34);
c=3*10^8;
mun=100;
taun=5*10^(-9);
mup=25;
taup=5*10^(-9);
e=8.854*10^(-12);
alpha=0.473;
We=50*10^(-9);
Wa=5*10^(-9);
ni=1;
%VD=-10:0.01:10;
q=1.602*10^(-19);
n=1.5;
k=1.38*10^(-23);
T=283;
Na=1*10^(14);
VT=((k*T)/q); %VT=KT/q
G= ((1-R)*(lamda*I))/(h*c);%G=(1-R)?I/hc
syms x
fn=int(1/(mun*taun*((q*Na*(x-Wa))/e)));
syms x
FN=int(exp(-(alpha+fn)),(We+Wa),(We+x));
Jn=q*G*alpha*exp(fn)*FN;
x=-10:0.01:10;
JN=subs(Jn);
syms x
fp=int(1/(mup*taup*((q*Na*(x-Wa))/e)));
syms x
FP=int(exp(-(alpha+fp)),(We+x),We);
Jp=q*G*alpha*exp(fp)*FP;
x=-10:0.01:10;
JP=subs(Jp);
Jph=JN+JP;
J0=((q*ni*Wa)/(2*sqrt(taun*taup)));
J=zeros(1,2003);
j=1;
J(1,1)=0;
for VL=0:0.001:5
Jpart=J0*(exp(VL-(J(j,1)*Rs)/(n*VT)))-1;
J(j+1)=-Jph+Jpart;
VL1(j+1)=VL;
j=j+1;
plot(VL1(j),J(j,1), 'r')
hold on
grid on
end
在这段代码中我收到错误:
在作业A(:) = B中,A和B中的元素数必须相同。
Code2中的错误(第49行) Ĵ(J + 1)= - JPH + Jpart;
我想获得如下图所示的输出:
没有输出。请有人帮帮我......
答案 0 :(得分:0)
检查你的模型是你的功课,并且充满了各种错误。但仅仅是代码,现在正在发挥作用:
<?php
ini_set('display_errors', 1);
$string="Hello world";
echo strReplace($string,"llo","zz");
echo strReplace($string,"o","xx");
function strReplace($string,$toReplace,$replacement)
{
while($indexArray=checkSubStringIndexes($toReplace,$string))
{
$stringArray= getChars($string);
$replaced=false;
$newString="";
foreach($stringArray as $key => $value)
{
if(!$replaced && in_array($key,$indexArray))
{
$newString=$newString.$replacement;
$replaced=true;
}
elseif(!in_array($key,$indexArray))
{
$newString=$newString.$value;
}
}
$string=$newString;
}
return $string;
}
function getLength($string)
{
$counter=0;
while(true)
{
if(isset($string[$counter]))
{
$counter++;
}
else
{
break;
}
}
return $counter;
}
function getChars($string)
{
$result=array();
$counter=0;
while(true)
{
if(isset($string[$counter]))
{
$result[]=$string[$counter];
$counter++;
}
else
{
break;
}
}
return $result;
}
function checkSubStringIndexes($toReplace,$string)
{
$counter=0;
$indexArray=array();
$newCounter=0;
$length= getLength($string);
$toReplacelength= getLength($toReplace);
$mainCharacters= getChars($string);
$toReplaceCharacters= getChars($toReplace);
for($x=0;$x<$length;$x++)
{
if($mainCharacters[$x]==$toReplaceCharacters[0])
{
for($y=0;$y<$toReplacelength;$y++)
{
if(isset($mainCharacters[$x+$y]) && $mainCharacters[$x+$y]==$toReplaceCharacters[$y])
{
$indexArray[]=$x+$y;
$newCounter++;
}
}
if($newCounter==$toReplacelength)
{
return $indexArray;
}
}
}
}