在Octave中未为N-d对象定义的转置

时间:2015-11-25 09:07:35

标签: multidimensional-array octave

我正在运行一个脚本文件(.m),它可以根据Table.csv中的表格从Test.txt生成大量csv文件:

function array()
fid=fopen('Test.txt')
A=[]
for i=1:800
  data=str2num(fgetl(fid))
  A=horzcat(A,data)
end
fclose(fid)
A=reshape(A,[30,40,20])
LO=[115.0,118.0,119.0,119.5,120.0,120.1,120.2,120.3,120.4,120.5,120.6,120.7,120.8,120.9,121.0,121.1,121.2,121.3,121.4,121.5,121.6,121.7,121.8,121.9,122.0,122.5,123.0,124.0,125.0,130.0]
LA=[15.0,21.0,21.5,21.8,22.0,22.1,22.2,22.3,22.4,22.5,22.6,22.7,22.8,22.9,23.0,23.1,23.2,23.3,23.4,23.5,23.6,23.7,23.8,23.9,24.0,24.1,24.2,24.3,24.4,24.5,24.6,24.7,24.8,24.9,25.0,25.2,25.4,26.0,27.0,30.0]
H=[-10.0,0,2.0,4.0,6.0,9.0,13.0,17.0,21.0,25.0,30.0,35.0,50.0,70.0,90.0,110.0,140.0,170.0,200.0,700.0]
Table=csvread('Table.csv')
row=size(Table,1)
[str,maxarray]=computer
[LAX,LOY,HZ]=meshgrid(LA,LO,H)
for i=5129:2:row
%{
[LOS,IXS]=min(abs(LO(:)-P(1,1)))
[LAS,IYS]=min(abs(LA(:)-P(1,2)))
[HS,IZS]=min(abs(H(:)-P(2,3)))
[LOD,IXD]=min(abs(LO(:)-P(2,1)))
[LAD,IYD]=min(abs(LA(:)-P(2,2)))
[HD,IZD]=min(abs(H(:)-P(2,3)))
%}
LOD=round(abs((Table(i+1,1)-Table(i,1)))/0.001)
LAD=round(abs((Table(i+1,2)-Table(i,2)))/0.001)
if Table(i,3)<Table(i+1,3)
    HD=round(abs(Table(i,3)-200)*10)
    PH=Table(i,3)
else
    HD=round(abs(Table(i+1,3)-200)*10)
    PH=Table(i+1,3)
end
if LOD*LAD*HD>237*430*2011
continue
else
    LOL=linspace(Table(i+1,1),Table(i,1),LOD)
    if Table(i+1,2)>Table(i,2)
        LAL=linspace(Table(i+1,2),Table(i,2)-0.001,LAD+1)
    else
        LAL=linspace(Table(i+1,2),Table(i,2)+0.001,LAD+1)
    end
    HL=linspace(PH,200,HD)
    [LALX,LOLY,HLZ]=meshgrid(LAL,LOL,HL)
    clear B LAL LOL HL
    B=interp3(LAX,LOY,HZ,A,LALX,LOLY,HLZ)
    clear LALX LOLY HLZ
    TableName=sprintf('Table%d_%d.csv',Table(i,4),i)
    csvwrite(TableName,B)
    TableDimName=sprintf('TableDim%d_%d.txt',Table(i,4),i)
    fileID = fopen(TableDimName,'w');
    fprintf(fileID,'%d %d %d\n',LOD,LAD+1,HD);
    fclose(fileID);
end
end
end

在Matlab中,它成功编译而没有任何警告。在Octave中,它显示以下错误:

error: transpose not defined for N-d objects
error: evaluating argument list element number 3
error: called from:
error:   /usr/share/octave/3.8.2/m/io/dlmwrite.m at line 193, column 7
error:   /usr/share/octave/3.8.2/m/io/csvwrite.m at line 35, column 3
warning: broken pipe
error:   /home/r02036/HuygenT/TableII/array.m at line 50, column 9

我知道这与多维阵列错误地使用转置的问题有关,但在这里我不使用它们中的任何一个。任何人都可以给我一个建议吗?谢谢!

0 个答案:

没有答案