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

    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.

    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?

  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

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