Image Matlab中的Lanread函数
我有一张多光谱图像,我有一个问题。我在网上找到了一个功能代码,可以读取这种图像。问题是我收到了以下错误:Image Matlab中的Lanread函数,image,matlab,Image,Matlab,我有一张多光谱图像,我有一个问题。我在网上找到了一个功能代码,可以读取这种图像。问题是我收到了以下错误: ??? function [lan_data] = lanread('montana.lan') | Error: Function definitions are not permitted in this context. 另外,当我检查“lanread”命令的帮助时,我收到了以下信息:“>>help landread” 找不到landread。“ 是否可能此命令不存在?我还没
??? function [lan_data] = lanread('montana.lan')
|
Error: Function definitions are not
permitted in this context.
另外,当我检查“lanread”命令的帮助时,我收到了以下信息:“>>help landread”
找不到landread。“
是否可能此命令不存在?我还没有找到这么多关于它的信息
提前感谢,
PD)这是功能代码
function [lan_data] = lanread('montana.lan','C:\formato_lan')
% LANREAD Read Landsat data file type .lan
% Ex: im = lanread('montana.lan')
% size(im) = [m,n,d];
% (From landsatdemo in the image analysis toolbox.)
% $Id: lanread.m 3325 2007-04-06 15:52:34Z finn $
if (nargin<2), thepath = []; end
if isempty(thepath)
[p,n,e]=fileparts(which('fms150path'));
thepath= {fullfile('.',filesep),...
fullfile(p,filesep,'data',filesep),...
fullfile(p,filesep,'data',filesep,'protected',filesep),...
fullfile(p,filesep,'data',filesep,'protected',filesep, ...
'lan',filesep),...
''};
elseif ischar(thepath)
thepath = {thepath};
end
fid = -1;
if (fid<0)
for path_idx=1:length(thepath)
filename = sprintf('%s%s',thepath{path_idx},lan_filename);
fid = fopen(filename,'r');
if (fid>=0), break; end
end
if (fid<0) % If not found anywhere
error(sprintf('Could not open file: %s',filename));
end
end
% find out how big the image is based on file size,
% assuming square image, 7 bands
nbands = 7;
fseek(fid,0,'eof');
file_bytes = ftell(fid);
nlines = floor(sqrt(file_bytes/nbands));
nsamples = nlines;
% skip header
nbytes_header = 128;
fseek(fid,nbytes_header,'bof');
% prepend * to read data into an array that has the same class as the data
A = fread(fid,[nsamples nlines*nbands],'*uint8');
fclose(fid);
% put data into a 3D array
A_3dim = reshape(A,nsamples,nbands,nlines);
lan_data = permute(A_3dim,[3 1 2]);
function[lan\u data]=lanread('montana.lan','C:\formato\u lan')
%LANREAD读取陆地卫星数据文件类型.lan
%例如:im=lanread('montana.lan'))
%尺寸(im)=[m,n,d];
%(来自图像分析工具箱中的landsatdemo。)
%$Id:lanread.m 3325 2007-04-06 15:52:34Z finn$
如果(纳金)
调用函数时(与定义函数相反),不需要使用关键字function
。因此,要使用函数,只需
[lan_data]=lanread('montana.lan')
声明函数时,必须使用关键字函数
,但必须使用参数名。因此文件lanread.m
中的第一行应该是
function [lan_data] = lanread(lan_filename, thepath)
而不是
function [lan_data] = lanread('montana.lan','C:\formato_lan')
只有在调用函数时,才使用值'montana.lan'
和'c:\formato\u lan'
作为参数
要获得帮助,您需要准确键入函数名
兰瑞德博士
而不是landread
谢谢Shai,我现在已经改变了:“[lan_data]=lanread('montana.lan','\formato_lan');”我已经检查了结构(doc lanread),它是正确的,但我收到了以下错误:“非法使用保留关键字“end”。“完全正确!非常感谢Shai!”)检查你的拼写-lanread还是lanread?