Function to read a file
7 次查看(过去 30 天)
显示 更早的评论
Hello! I have m file for reading ape format files and working with it. Can i make a function like this
% ReadingApe m-file name
ReadingApe('C:/f1p2010.ape')
% and she would give me everything there is
a=[...];
b=[...]
inta=[...]
intb=[...]
now it looks like this
file='C:/f1p2010.ape' % I'm interested in this part, where the file is selected
filedata = fopen(file);
a=fread(filedata) b=fread(filedata)
while
inta=a(i)+1
inta=b(i)+1
end
is it possible to do so, but so that I can choose the files myself?
function ReadingApe
filedata = fopen(file);
a=fread(filedata) b=fread(filedata)
while
inta=a(i)+1
inta=b(i)+1
end
end
0 个评论
回答(1 个)
Rik
2020-3-20
The function signature below makes more sense to me.
function [a,b,inta,intb]=ReadingApe(file)
Then you can input your variable with the file name. The while loop you have put in your code doesn't make sense, nor the space in the third line of your function, but I'll assume it is just an example.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!