matlab输入的参数数目不足 55
新建了.m文件直接粘贴的以下代码,运行时提示参数数目不足function[vlonvlatvhgt]=read_SRTMtile(filename,sc)%%%parse...
新建了.m文件 直接粘贴的以下代码,运行时提示参数数目不足
function [vlon vlat vhgt] = read_SRTMtile(filename,sc)
%%% parse filename, 'y' refers to latitude, 'x' to longitude
yllcorner = str2double(filename(1,2:3));
xllcorner = str2double(filename(1,5:7));
if (strcmp(filename(1,1),'S') || strcmp(filename(1,1),'s')); yllcorner = -yllcorner; end
if (strcmp(filename(1,4),'W') || strcmp(filename(1,w),'w')); xllcorner = -xllcorner; end
%%% 3-arc second assumption
cellsize = 3/3600; % 3 arc-second, fixed
nrows = 1201; % fixed for 3-arcsec data
ncols = 1201; % fixed for 3-arcsec data
%%%
j_lon = (1:1:ncols)'; lan_lon = xllcorner + cellsize*(j_lon -1);
%%% do it
vlon = []; vlat = []; vhgt = [];
tic;
fid_in = fopen(filename,'r','ieee-be');
for i =1:1:nrows
v_hgt = fread(fid_in,ncols,'int16');
v_lon = lan_lon;
v_lat = (yllcorner + cellsize*(nrows-i)) * ones(ncols,1);
vlon = [vlon; v_lon]; vlat = [vlat; v_lat]; vhgt = [vhgt; v_hgt];
end
fclose(fid_in);
toc
g = (vhgt < -32700); % set data voids to NaN
vhgt(g) = NaN;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% spot check
if nargin > 1
j = floor(0.01*nrows); figure(11);
scatter3(vlon(1:j:end),vlat(1:j:end),vhgt(1:j:end),10,vhgt(1:j:end),'filled');
view([0 90]); xlabel('Longitude'); ylabel('Latitude');
title([' Height in m for tile: ' filename]); colorbar;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 展开
function [vlon vlat vhgt] = read_SRTMtile(filename,sc)
%%% parse filename, 'y' refers to latitude, 'x' to longitude
yllcorner = str2double(filename(1,2:3));
xllcorner = str2double(filename(1,5:7));
if (strcmp(filename(1,1),'S') || strcmp(filename(1,1),'s')); yllcorner = -yllcorner; end
if (strcmp(filename(1,4),'W') || strcmp(filename(1,w),'w')); xllcorner = -xllcorner; end
%%% 3-arc second assumption
cellsize = 3/3600; % 3 arc-second, fixed
nrows = 1201; % fixed for 3-arcsec data
ncols = 1201; % fixed for 3-arcsec data
%%%
j_lon = (1:1:ncols)'; lan_lon = xllcorner + cellsize*(j_lon -1);
%%% do it
vlon = []; vlat = []; vhgt = [];
tic;
fid_in = fopen(filename,'r','ieee-be');
for i =1:1:nrows
v_hgt = fread(fid_in,ncols,'int16');
v_lon = lan_lon;
v_lat = (yllcorner + cellsize*(nrows-i)) * ones(ncols,1);
vlon = [vlon; v_lon]; vlat = [vlat; v_lat]; vhgt = [vhgt; v_hgt];
end
fclose(fid_in);
toc
g = (vhgt < -32700); % set data voids to NaN
vhgt(g) = NaN;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% spot check
if nargin > 1
j = floor(0.01*nrows); figure(11);
scatter3(vlon(1:j:end),vlat(1:j:end),vhgt(1:j:end),10,vhgt(1:j:end),'filled');
view([0 90]); xlabel('Longitude'); ylabel('Latitude');
title([' Height in m for tile: ' filename]); colorbar;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 展开
1个回答
展开全部
function [vlon vlat vhgt] = read_SRTMtile(filename,sc)
function的输入,filename和sc需要赋值
function的输入,filename和sc需要赋值
追问
谢谢,请问这个能读取hgt文件吗,遇到个问题就是,怎么用MATLAB读取hgt文件
追答
不能直接读取,先要转换;
1.由于arcgis似乎不能直接打开hgt文件,你把文件后缀改成.img先,用arcgis打开
2.在图层窗口中右键点击文件export data成tif文件
3.这时候的tif文件时int16的,还是不能用matlab打开
4.在Erdas里打开这个tif图,DataPrep->SubsetImage,然后选择Float Single,然后保存成tif图,这样保存以后的tif图就是32-bit floating-point的了,符合了matlab读tif的要求
5.用matlab,a=imread('我的dem.tif');
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询