1. Limited time only! Sign up for a free 30min personal 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!

Matlab: creating a table of equations using multiple variables

  1. Oct 22, 2012 #1
    1. The problem statement, all variables and given/known data
    I have an equation that looks like func=sin(pi*x*n)*sin(pi*y*m) I was wondering if there was any method (possibly involving for loops) where I could get a plottable function along xy for all the different combinations of n and m
    i.e. m= 1 n =1
    so the function would be
    sin(pi*x*1)*sin(pi*y*1)
    then m=1 n=2
    sin(pi*x*1)*sin(pi*y*2)
    and so on...
    so basically it would create m*n equations


    2. Relevant equations



    3. The attempt at a solution
    i tried something like
    x=1:10;
    y=1:10;
    n=1:10;
    m=1;10;
    for i=1:length(x)
    for ii=1:length(n)
    for iii=1:length(y)
    for iiii=1:length(m)
    QQ(i)=sin(pi*x(i)*n(ii))*sin(pi*y(iii)*m(iiii))
    end
    end
    end
    end

    but this i assume yields 10 values which correspond to when x y n m all equal the same values on the for loops. i.e. the first value is when x,y,n,m = 1 and the second value is when x,y,n,m = 2 etc.
     
  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



Similar Discussions: Matlab: creating a table of equations using multiple variables
Loading...