Matlab: how to use an array in a matrix

  • Context: MATLAB 
  • Thread starter Thread starter elham.n
  • Start date Start date
  • Tags Tags
    Array Matlab Matrix
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 4K views
elham.n
Messages
4
Reaction score
0
hi all..

I have a 2x2 matrix and an array , for example:

a=linspace(0,12) %this is my frequency range.

B=[2*a 3*a-1
a./2 a]

this one does not results a 2x2 matrix, that I need it to have ...B2xB1xB
how could i get a 2x2 matrix? should i use a loop instead of an array?
tnx a lot.

Elham
 
Physics news on Phys.org
With what?

What you have here a 2x2x100 array -- which is exactly what you asked for. You just don't know that that is what you asked for.

What you want is something different, apparently a plain old vanilla 2x2 matrix. I don't know how to read your mind, let alone a dumb program like Matlab. It only does what you tell it to do. Matlab, like all other languages built to date, does not have a DWIM (do what I mean) command.
 
I know what u mean!and I do not expect MATLAB to do s.th strange..
I want to replace this array's elements in this matrix.
i will use a matrix like this as the transfer matrix in PC structures,and multiplicantion of these matrices for every layer,but with this selected array , i face some problems. and multiplicantion of these matrices is impossible.
so i need square matrix..and I was only confused
tnx a lot..I solved this problem with a FOR loop.
thank u.