convert IDL code to matlab?

9 次查看(过去 30 天)
ALI HADDACH
ALI HADDACH 2020-7-7
Hey, I'm trying to convert a IDL code to matlab, in fact i have a idl code in which it creats a bathymetry file .bot (means that the file.bot contain a value of bathymetry but in meshs). Hope you understand me, i will let my code here so you can check it.
;pro to format the bathymetric data for swan use
device, true=24, decomposed=0, retain=2
!P.BACKGROUND=255
tek_color & black=0 & white=1 & red=2 & green=3 & dk_blue=4 & lt_blue=5 & pink=6 & yellow=7 & orange=8 & md_blue=11 & dk_grey=14 & lt_grey=15
bathy_file='/data/Etudiants_encadrement/Etudiants_Mordane/Lahcen_Benya/emodnet_mean_TEST.asc'
headers=6
delimiter=' '
bathy=read_ascii(bathy_file, data_start=headers,delimiter=delimiter)
bathy=bathy.(0)
data_size=size(bathy)
x_size=data_size(1)
y_size=data_size(2)
!order=1
lodct=13
stop
;window,xsize=650,ysize=y_size
;tv,bathy[0:649,*]
meshes=167
nb_meshes=1
new_tab=fltarr(167,y_size)
new_tab=bathy[0:166,*]
;stop
;window,xsize=650,ysize=y_size
index_nan=where(new_tab le -32767)
new_tab(index_nan)=!values.f_NaN
formated_table_bath=fltarr(meshes,y_size*nb_meshes)
;stop
Tab_tmp=fltarr(meshes,1)
for i=0,nb_meshes-1 do begin
j=0
for row=0,y_size-1 do begin
j=j+1
;for col=meshes*i,meshes*(i+1)-1 do begin
formated_table_bath(*,j*(i+1)-1)=string(new_tab(meshes*i:meshes*(i+1)-1,row),format='(f10.3)')
print,new_tab(meshes*i:meshes*(i+1)-1,row)
print,formated_table_bath(*,0)
;stop
;endfor
;print,new_tab(meshes*i:meshes*(i+1)-1,row)
;stop
endfor
endfor
Bathy_with_blanc=fltarr(170,y_size*nb_meshes)
Bathy_with_blanc(*,*)=999.999;!values.f_NaN
Bathy_with_blanc(0:meshes-1,0:y_size*nb_meshes-1)=formated_table_bath(*,*)
help,formated_table_bath
;stop
file_formated_bathy_tarfaya='/data/Etudiants_encadrement/Etudiants_Mordane/Lahcen_Benya/emodnet_format_lahcen_new_one.txt'
openw,1,file_formated_bathy_tarfaya
printf,1,'NCOLS 160 NROWS 76 XLLCORNER -8.712158203125 YLLCORNER 33.14849853515625'
printf,1,'CELLSIZE 0.002083333333299996'
printf,1,'NODATA_VALUE -32767.0'
printf,1,Bathy_with_blanc,format='(10(f10.3,1x))'
close,1
;tv,new_tab
;stop
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by