Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MatLab Matrix Help

  1. Jul 21, 2011 #1
    Hi,

    I have a quick question regarding MatLab.

    I have 3 matracies A, B and C.

    For every entry equal to 1 in B, I want to let the corresponding entry in A be an integral of x from 0 to C.

    ex.
    for all (i,j)
    if B(i,j)==1 then let A(i,j)=quad(@(x) x, 0, C(i,j))

    A quick way to do this for large matracies I thought was to use the following syntax:
    A(B==1) = quad(@(x) x, 0, C(B==1))

    But get the following error:
    ??? Error using ==> quad at 70
    The limits of integration must be scalars.


    Is there any way around this other than a "for i, for j" statement?

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

Can you offer guidance or do you also need help?
Draft saved Draft deleted