Loading a file into a variable in funtion
1 次查看(过去 30 天)
显示 更早的评论
I want to load a file in a variable in a function but when I do thta , matlab gives the file 's data in his own variable "ans"
function data=read_data(i)
data=load(num2str(i));
end
1 个评论
回答(1 个)
Sulaymon Eshkabilov
2023-1-11
How you can call a function to load a data file, e.g.:
FName = 'MY_data'; % .txt data files that all contain the sequential name: MY_data1.txt, MY_data2.txt, etc.
N = input('Enter the number of data files to load: ');
for ii = 1:N
Name = stcat([FName, num2str(ii) '.txt']);
data{ii} = read_data(Name);
end
function data=read_data(Name)
data=load(Name);
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!