I am trying to find the maximum and minimum values from a given set of data.

when I am using findpeaks command in Matlab I am only getting the peak value I also want the minimum value could you suggest which command I can use.I am also attaching the data file which includes one column of time and one column of stress signals.I have also attach the Matlab file,please find the attachment

 Accepted Answer

Hello!
Maybe you can first import the data into a vector and then look for the maximum and minimum like this:
A=importdata('sl.txt');
B=A.data;
mx=max(B(:,2))
mn=min(B(:,2))
This code should work!
Pedro

More Answers (1)

To find the "valleys", simply invert the signal
[peakHeights, indexesOfPeaks] = findpeaks(stress);
[valleyHeights, indexesOfValleys] = findpeaks(-stress); % Note the minus sign!
valleyHeights = abs(valleyHeights); % Correct for inverting it.

4 Comments

thanks a lot for your answer I now understand my mistake but after this when I am trying to write the rain flow script in order to reduce a spectrum of varying stress there is this error which is showing"Error using load Must be a string scalar or character vector.I am also attaching the script thanks in advance for your help.
You say:
load(i+1:i+2)=[];
but load() is a function that takes a filename string. However you're using it as an array. The solution is simple: use a different name for your "load" variable so that it does not conflict with a built in function.
yeah I got your point that load is a function that takes file name string so what can I use to copy the ith element of the array "load" to the variable s1?
Again, don't call it load. Call it thisLoad or something. Then to copy the ith element of that to s1, do this
s1 = thisLoad(i);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!