How to do this vector operation in MATLAB ?

In summary, the conversation is about a person seeking help with creating a MATLAB simulation of a race track. They have provided some vectors and information about the desired output, but need more guidance on how to approach the problem. They are also unsure of how to start a new thread on the forum.
  • #1
dexterdev
194
1
Hi friends,
I wanted a help in Matlab programming. I have some vectors as below :

d4=cos(2*pi*293.665*(0:1/44100:.25));
f4=cos(2*pi*349.228*(0:1/44100:.25));
e4=cos(2*pi*329.628*(0:1/44100:.25));
g4=cos(2*pi*391.995*(0:1/44100:.25));
c5=cos(2*pi*523.251*(0:1/44100:.25));
bb4=cos(2*pi*466.164*(0:1/44100:.25));
a4=cos(2*pi*440*(0:1/44100:.25));
c4=cos(2*pi*261.626*(0:1/44100:.25));

and finally a vector x build from the above vectors :

x=[c4 c4 d4 c4 f4 e4 c4 c4 d4 c4 g4 f4 c4 c4 c5 a4 f4 e4 d4 bb4 bb4 a4 f4 g4 f4];

here a4 must be assigned 1, bb4 - 2, c4 - 3, d4 - 5, e4 - 6 , f4 - 7 and g4 - 8. I wanted to create a vector y from x. y must be as below :

y = [3 3 5 3 7 6 3 3 5 3 8 7 3 3 4 1 7 6 5 2 2 1 7 8 7] ;

TIA
 
Physics news on Phys.org
  • #2
Some more information would help here. Based on what you've written it looks like typing in that vector works just fine, given that you want to take a vector with 275k+ elements and turn it into one with 25.
 
  • #3
Track representation in Matlab

Hi,

I was wondering if anyone could help me. I need to simulate a race track using MATLAB and do not know how to go about this?

Any suggestions welcome.

Thank you
 
  • #4
RacingFan, start a new thread and include as much information as possible on the problem,as well as what you've tried already.
 
  • #5
How do i start a new thread? sorry new to this!
 
  • #6

1. How do I add two vectors in MATLAB?

To add two vectors in MATLAB, you can use the "plus" operator (+) or the built-in function "plus()". For example, if vector A = [2 4 6] and vector B = [1 3 5], then A + B or plus(A,B) will result in the vector [3 7 11].

2. Can I multiply a vector by a scalar in MATLAB?

Yes, you can multiply a vector by a scalar in MATLAB using the "times" operator (*) or the built-in function "times()". For instance, if vector A = [1 2 3] and scalar b = 2, then A * b or times(A,b) will give you the vector [2 4 6].

3. How do I calculate the dot product of two vectors in MATLAB?

To calculate the dot product of two vectors in MATLAB, you can use the "dot" function. For example, if vector A = [1 2 3] and vector B = [4 5 6], then dot(A,B) will give you the result of 32 (1*4 + 2*5 + 3*6).

4. Can I find the cross product of two vectors in MATLAB?

Yes, you can find the cross product of two vectors in MATLAB using the "cross" function. For instance, if vector A = [1 2 3] and vector B = [4 5 6], then cross(A,B) will result in the vector [-3 6 -3].

5. How do I find the magnitude of a vector in MATLAB?

To find the magnitude of a vector in MATLAB, you can use the "norm" function. For example, if vector A = [3 4], then norm(A) will give you the result of 5, which is the magnitude of the vector.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
566
  • Introductory Physics Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
895
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
351
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top