Matlab: creating a table of equations using multiple variables

In summary, the individual is asking for a method to create a plotable function along xy for all combinations of n and m, with the equation func=sin(pi*x*n)*sin(pi*y*m). They have attempted a solution using for loops, but it only yields 10 values and they are looking for a plotable function with m*n elements. They are new to Matlab and seeking help with this problem.
  • #1
Samefiddle
1
0

Homework Statement


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


Homework Equations





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.
 
Physics news on Phys.org
  • #2
what i want is a plotable function of x and y that changes based on the values of n and m, so basically QQ has to be m*n elements not just 10. I am new to Matlab so if anyone can help me I would really appreciate it.
 

Related to Matlab: creating a table of equations using multiple variables

1. How do I create a table of equations using multiple variables in Matlab?

To create a table of equations using multiple variables in Matlab, you can use the "table" function and specify the variables and equations you want to include. For example:

x y z
1 2 x+y
3 4 x*y+z

2. Can I use different types of equations in the same table in Matlab?

Yes, you can use different types of equations in the same table in Matlab. You can mix arithmetic, logical, and relational operators to create complex equations. For example:

x y z
1 2 x+y <= 5
3 4 x*y >= z

3. How can I add headers and titles to my table in Matlab?

You can use the "VariableNames" and "RowNames" arguments in the "table" function to add headers and titles to your table. For example:

Variable A Variable B Result
1 2 x+y
3 4 x*y+z

4. Is it possible to plot the equations in my table in Matlab?

Yes, you can plot the equations in your table in Matlab by using the "plot" function and specifying the table variables as the x and y values. This will create a separate plot for each equation in your table. For example:

5. Can I export my table of equations from Matlab to a spreadsheet?

Yes, you can export your table of equations from Matlab to a spreadsheet by using the "writetable" function and specifying the file name and format. This will create a spreadsheet with the table data and equations. For example:

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
846
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
978
  • Engineering and Comp Sci Homework Help
Replies
2
Views
873
  • Engineering and Comp Sci Homework Help
Replies
1
Views
935
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
920
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
Back
Top