how to find max and min value from .mat file and save it to an other array?
5 次查看(过去 30 天)
显示 更早的评论
for i=1:10
j(i)=i*0.5:
end
j = sort( j );
save('j.mat', 'j');
how can i find the max and min value from j.mat and save it to an other array?
0 个评论
采纳的回答
Thorsten
2015-9-22
S = load('j.mat', 'j');
minmax = [min(S.j) max(S.j)];
save('jminmax.mat', minmax);
0 个评论
更多回答(1 个)
Nobel Mondal
2015-9-22
Looks like the input array is already being sorted before saving into matfile. Now all you have to do is load the file, and get the first and last elements from the array.
>> load j % Here j is the matfile name
>> min_num = j(1); % Here j is array variable name
>> max_num = j(end); % Here J is again variable name
>> new_array = [min_num max_num];
2 个评论
Nobel Mondal
2015-9-22
编辑:Nobel Mondal
2015-9-22
While saving the matfile, probably the variables were not saved properly. Can you try "clear all", then double click on the j.mat file and see if any variable comes up in the Workspace window?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!