how to import image file in MATLAB
조회 수: 8 (최근 30일)
이전 댓글 표시
In following code there a error comes in "fileToRead1". So how to debug the following code.
function importfile(fileToRead1)
%IMPORTFILE(FILETOREAD1)
% Imports data from the specified file
% FILETOREAD1: file to read
% Auto-generated by MATLAB on 11-Dec-2012 09:34:02
% Import the file
%rawData1 = importdata(fileToRead1);
% For some simple files (such as a CSV or JPEG files), IMPORTDATA might
% return a simple array. If so, generate a structure so that the output
% matches that from the Import Wizard.
[~,name] = fileparts(fileToRead1);
newData1.(genvarname(name)) = rawData1;
% Create new variables in the base workspace from those fields.
vars = fieldnames(newData1);
for i = 1:length(vars)
assignin('base', vars{i}, newData1.(vars{i}));
end
??? Input argument "fileToRead1" is undefined.
Error in ==> importfile at 14
[~,name] = fileparts(fileToRead1);
댓글 수: 0
답변 (1개)
Walter Roberson
2012년 12월 11일
How are you invoking this function? The function is expecting you to pass a file name in. You cannot start this function by pressing F5: you need to start it at the command line or call it from another routine. For example, at the command line,
importfile('C:/TEMP/cameraman.tif');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!