How multiply cos and sin (eg. cos(pi*x).*sin(pi*y))
Show older comments
Hi All,
I have a value for out1 using the below code
out1=double(int(int((exp(x+y)*cos(pi*x)*cos(pi*y)),x,-1,1),y,-1,1))
I would like to multiply cos(pi*x).*sin(pi*y)) by out1 by passing the same range for x and y.
My code is like below
out1=double(int(int((exp(x+y)*cos(pi*x)*cos(pi*y)),x,-1,1),y,-1,1))
answer1=cos(pi*x).*sin(pi*y)
answer2 = out1.*answer1
I am getting the below error,
Error using *
Inner matrix dimensions must agree.
Thanks,
With regards,
GK.Jagatheswari
Answers (1)
Image Analyst
on 1 Apr 2014
Are x and y arrays? Or scalars in a loop?
whos x
whos y
What does it report in the command window? It seems like they're arrays, and it so you must use .* instead of * before the cos()
out1=double(int(int((exp(x+y) .* cos(pi*x) .* cos(pi*y)),x,-1,1),y,-1,1))
because you're multiplying an array by an array element-by-element. Otherwise it will do a matrix multiplication and you'll get an error message like that.
2 Comments
jagatheswari kathirvel
on 1 Apr 2014
Image Analyst
on 1 Apr 2014
Give the exact error message. Quit snipping out just a part of it. Post ALL the red text, line number, everything .
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!