1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Array with complex expression

  1. Jun 14, 2014 #1

    Maylis

    User Avatar
    Gold Member

    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:

    Last edited: Jun 14, 2014
  2. jcsd
  3. Jun 14, 2014 #2

    Maylis

    User Avatar
    Gold Member

    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

     
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Array with complex expression
  1. Function and array (Replies: 26)

Loading...