# Array with complex expression

1. Jun 14, 2014

### Maylis

1. The problem statement, all variables and given/known data
I am working on problem 4 in the PDF attachment now, but I will show my code for 2 and 3 since they are related to 4. The values for 2 and 3 were given in the editor.

2. Relevant equations

3. The attempt at a solution

2.
Code (Text):
P = [1.6, 4, 2.9, -8];
N = 3;
PextDown = repmat(P,3,1);
EDU>> PextDown

PextDown =

1.6000    4.0000    2.9000   -8.0000
1.6000    4.0000    2.9000   -8.0000
1.6000    4.0000    2.9000   -8.0000
3.
Code (Text):
D = [7.2;-3.1;1.3];
M = 4;
DextAcross = repmat(D,1,4);
EDU>> DextAcross

DextAcross =

7.2000    7.2000    7.2000    7.2000
-3.1000   -3.1000   -3.1000   -3.1000
1.3000    1.3000    1.3000    1.3000
4.
What the heck are they trying to get me to do with this e^(complex stuff) using these arrays?? I don't really even comprehend the question to start this thing. My current thought is that they want something like this
Code (Text):
fDP =(1/(1+DextAcross.^2+PextDown.^2))+exp(-abs(DextAcross)*cos(DextAcross*PextDown));
Error using  /
Matrix dimensions must agree.

#### Attached Files:

• ###### Problem 4.pdf
File size:
26.1 KB
Views:
59
Last edited: Jun 14, 2014
2. Jun 14, 2014

### Maylis

It turns out that you need to put a period (.) before arithmetic operations involving either 2 matrices or a matrix and a scalar.

Code (Text):
fDP = (1./(1+DextAcross.^2+PextDown.^2))+exp(-abs(DextAcross).*cos(DextAcross.*PextDown));

fDP =

0.0452  506.7186   24.4058    0.0366
0.5437    0.0846   16.6889    0.0668
2.0751    0.5974    2.9525    2.0886