What's wrong with this code?
显示 更早的评论
Every time I run this code an error message appears saying '??? undefined function or method 'img' for input arguments of type 'char'.' I am attempting to view a coded image. What is the problem? Thanks,
clear all; clc;
[FileName,path] = uigetfile({'*.img'},'Choose ASL Label File');
k = length(FileName);
file = FileName(1:(k-4));
filenameh=strcat(path,FileName(1:(k-3)),'hdr');
fidh = fopen(filenameh,'r','b');
fseek(fidh,40,'bof');
fseek(fidh,40,'bof');
dim = fread(fidh,8,'int16');
hdrsize = fread(fidh,1,'int32','l');
if hdrsize == 348
datatype = 'l';
else
datatype = 'b';
end
data_format=fread(fidh,8,'int16',datatype);
if data_format(6)==4
form = 'short';
elseif data_format(6) ==16
form = 'float';
else
disp('Problem Reading In File')
quit cancel
end
xdim = dim(2);ydim = dim(3);zdim = dim(4);vols = dim(5);
disp('Analysing ....')
lab1f = strcat(path,file,'.img');
l1fid=fopen(lab1f,'r',datatype);
lab1=fread(l1fid,form);
lab1=reshape(lab1,xdim,ydim,zdim,vols);
2 个评论
Geoff Hayes
2014-7-5
Jack - if including code in your question (instead of attaching it using the paper clip button) please ensure that it is formatted correctly to improve readability. Highlight the code portions of the question and press the {} Code button.
The undefined function or method message typically means that the code is using something as a function which is not defined or found in the MATLAB search path, or it is invalid for inputs of a certain type. Your error message is for something called img which I don't see anywhere in your code except as a file extension.
Have you included all the code relevant to this question? What is the line number that has generated this error?
Image Analyst
2014-7-5
Please include the entire error message - ALL THE RED TEXT - don't snip or paraphrase it at all. By leaving out vital information (so far), you've prevented anyone from pinpointing and fixing your error.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!