Got Questions? Get Answers.
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:
how to copy values in a vector

Subject: how to copy values in a vector

From: Regina

Date: 5 Mar, 2009 03:10:03

Message: 1 of 5

hi! i'm new in matlab.

i have a problem in creating a new vector that will include two values.
i have a variable max and min which are both double array that has both 2 columns each. the size of the rows can be changing but now the size that i have is a 4X2 double array. i want both max and min to be in one vector so that i can use xcorr function on the vector. hope someone will help me.

thanks!

Subject: how to copy values in a vector

From: Diego Zegarra

Date: 5 Mar, 2009 03:33:02

Message: 2 of 5

suppose your vector is a,

min_val = min(min(a));
max_val = max(max(a));

Vector = [min_val max_val]

Subject: how to copy values in a vector

From: Matt Fig

Date: 5 Mar, 2009 03:46:02

Message: 3 of 5

"Regina " <velasquezregina@rocketmail.com> wrote in message <gonfqb$gi$1@fred.mathworks.com>...
> hi! i'm new in matlab.
>
> i have a problem in creating a new vector that will include two values.
> i have a variable max and min which are both double array that has both 2 columns each. the size of the rows can be changing but now the size that i have is a 4X2 double array. i want both max and min to be in one vector so that i can use xcorr function on the vector. hope someone will help me.
>
> thanks!


It sounds like you have one variable named max, and another named min. It is always a bad idea to name variables the same name as Matlab functions. I will call your variables MAX and MIN to avoid confusion.

v1 = MAX(:); % Turns the array MAX into a column vector named v1.
v2 = MIN(:); % Turns the array MIN into a column vector named v2.






,eM[QyWQET[XOrMk`Q&MM\O[ZkMaXM`bUk1a[SYkkYT`9QN[kkN[T\MkZUr

Subject: how to copy values in a vector

From: Andrei

Date: 5 Mar, 2009 03:45:19

Message: 4 of 5

If I understand the problem correctly, you might do something like this:

% your variables
m1=rand (4,2);
m2=rand (4,2);

% make them vectors
m1=m1(:);
m2=m2(:);

now, obviously using xcorr means that the actual position at which you have the values makes a big difference, so depending on your final goal, you may want to transpose the arrays before you convert them to vectors.

good luck!
Andrei

Subject: how to copy values in a vector

From: Regina

Date: 7 Mar, 2009 10:25:03

Message: 5 of 5

"Diego Zegarra" <diegozbb@gmail.com> wrote in message <gonh5e$18a$1@fred.mathworks.com>...
> suppose your vector is a,
>
> min_val = min(min(a));
> max_val = max(max(a));
>
> Vector = [min_val max_val]

hi! thanks for your answers! it was really helpful

by the way. i have another question here.
do you know how to determine the cyclic component of a signal.
i have a signal which is in a vector.
this vector contains all the aspect ratios that was computed from a given bounding box.
i now need to compare each cycle(the signal is not periodic but is a sine wave) of the signal from one another.
i hope you can help me again with this one!

Tags for this Thread

No tags are associated with 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