Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Save max values and locations to a matrix

Subject: Save max values and locations to a matrix

From: Susan

Date: 31 Aug, 2011 14:35:29

Message: 1 of 3

Hi all,

I want to output the max XCF value of the below nested for loop. I can do this fine with function max of course, but I would like to save the locations (i.e. x and y values, (j-i)/2000 & maxXCF, respectively) of these maxima to a matrix after the entire iteration. (The first loop has many more values; this was just to test.)

If anyone could please suggest how to do this I would be very grateful! :)

------------------------------------------------------------------------------------------------------------------------

countx = 1;
threshold = 70; % i.e. 10 times the anticipated frame number

for i = 1
    for j = i:(i+threshold)
        [XCF, Lags] = crosscorr(data_A(:,i),data_B(:,j),N-1,1);
        maxXCF(j) = max(XCF);
        figure(2);
        plot(((j-i)/2000),maxXCF(j),'-.ro'); hold all;
        countx = countx+1;
    end
end

Subject: Save max values and locations to a matrix

From: someone

Date: 31 Aug, 2011 14:57:28

Message: 2 of 3

"Susan" wrote in message <j3lgrh$2k1$1@newscl01ah.mathworks.com>...
> Hi all,
>
> I want to output the max XCF value of the below nested for loop. I can do this fine with function max of course, but I would like to save the locations (i.e. x and y values, (j-i)/2000 & maxXCF, respectively) of these maxima to a matrix after the entire iteration. (The first loop has many more values; this was just to test.)
>
> If anyone could please suggest how to do this I would be very grateful! :)
>
> ------------------------------------------------------------------------------------------------------------------------
>
> countx = 1;
> threshold = 70; % i.e. 10 times the anticipated frame number
>
> for i = 1
> for j = i:(i+threshold)
> [XCF, Lags] = crosscorr(data_A(:,i),data_B(:,j),N-1,1);
> maxXCF(j) = max(XCF);
> figure(2);
> plot(((j-i)/2000),maxXCF(j),'-.ro'); hold all;
> countx = countx+1;
> end
> end

doc max

Look at the second output:

[C,I] = max(...) finds the indices
of the maximum values of A, and returns them in output
vector I. If there are several identical maximum values,
the index of the first one found is returned.

Subject: Save max values and locations to a matrix

From: Susan

Date: 1 Sep, 2011 08:46:27

Message: 3 of 3

Thank you kindly :)

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us