delphi动态数组出错
procedureTForm1.Button5Click(Sender:TObject);varmyinifile:Tinifile;i:Integer;pixels,d...
procedure TForm1.Button5Click(Sender: TObject);
var myinifile:Tinifile;
i: Integer;
pixels,darkpixels,a,stand: array of Double;
wavelengths: array of Double;
numberOfPixels: Integer;
begin
begin
wrapper.setIntegrationTime(0, (StrToInt(form1.IntegrationTime.Text)));
pixels := wrapper.getSpectrum(0);
wavelengths := wrapper.getWavelengths(0);
numberOfpixels:=wrapper.getNumberOfPixels(0); //从光谱仪采集数据
k:=0;
for i:=0 to numberOfPixels-1 do
begin
if pixels[i]>300 then
if pixels[i]<1000 then
begin
darkpixels[k]:=pixels[i];
k:=k+1; //取出pixels数组中300到1000的数
end;
end;
setlength(a,k); //是不是setlength有问题?
for i:=0 to k-1 do
begin
stand[i]:=strtofloat(advstringgrid1.Cells[2,i]);
pixels[i]:=strtofloat(advstringgrid2.Cells[1,i]);
end;
for i:=0 to k-1 do
a:=stand[i]*((StrTofloat(IntegrationTime.Text)/1000000)*0.26*1)/(pixels[i]-darkpixels[i]);
//计算公式这出错,extended and dynamic array
advstringgrid2.Cells[2,i]:= floattostr(a[i]);
end; 展开
var myinifile:Tinifile;
i: Integer;
pixels,darkpixels,a,stand: array of Double;
wavelengths: array of Double;
numberOfPixels: Integer;
begin
begin
wrapper.setIntegrationTime(0, (StrToInt(form1.IntegrationTime.Text)));
pixels := wrapper.getSpectrum(0);
wavelengths := wrapper.getWavelengths(0);
numberOfpixels:=wrapper.getNumberOfPixels(0); //从光谱仪采集数据
k:=0;
for i:=0 to numberOfPixels-1 do
begin
if pixels[i]>300 then
if pixels[i]<1000 then
begin
darkpixels[k]:=pixels[i];
k:=k+1; //取出pixels数组中300到1000的数
end;
end;
setlength(a,k); //是不是setlength有问题?
for i:=0 to k-1 do
begin
stand[i]:=strtofloat(advstringgrid1.Cells[2,i]);
pixels[i]:=strtofloat(advstringgrid2.Cells[1,i]);
end;
for i:=0 to k-1 do
a:=stand[i]*((StrTofloat(IntegrationTime.Text)/1000000)*0.26*1)/(pixels[i]-darkpixels[i]);
//计算公式这出错,extended and dynamic array
advstringgrid2.Cells[2,i]:= floattostr(a[i]);
end; 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询