how to find max and min value from .mat file and save it to an other array?

조회 수: 10 (최근 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?

채택된 답변

Thorsten
Thorsten 2015년 9월 22일
S = load('j.mat', 'j');
minmax = [min(S.j) max(S.j)];
save('jminmax.mat', minmax);

추가 답변 (1개)

Nobel Mondal
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
Muhammad Umer
Muhammad Umer 2015년 9월 22일
load j;
min_value=j(1);
max_value=j(end);
new_array = [min_value max_value];
i am getting this error.
??? Undefined function or variable 'j'.
Error in ==> load_files at 2
min_value=j(1);
Nobel Mondal
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 CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by