how to properly write this equation exp(x)cos(y)
Show older comments
I wrote it like exp(x).*cos(y) but I kept getting "Matrix dimensions must agree" as output
3 Comments
Walter Roberson
on 28 Nov 2017
What are size(x) and size(y) and what size of output are you expecting?
Chrystian McCollum
on 28 Nov 2017
Walter Roberson
on 28 Nov 2017
Your y is 5 x 5. Your x is 26 x 26. What size of output are you looking for?
Accepted Answer
More Answers (1)
John D'Errico
on 28 Nov 2017
An interesting, creative, yet terrible use of meshgrid. Instead, do this:
[x,y] = meshgrid(-2*pi:0.5:2*pi,-1:0.5:1);
Read the help when you will use a function you don't understand. Try some simple examples. Think about what you see in those examples.
By the way, This is usually a bad idea:
-2*pi:0.5:2*pi
ans =
Columns 1 through 13
-6.2832 -5.7832 -5.2832 -4.7832 -4.2832 -3.7832 -3.2832 -2.7832 -2.2832 -1.7832 -1.2832 -0.78319 -0.28319
Columns 14 through 26
0.21681 0.71681 1.2168 1.7168 2.2168 2.7168 3.2168 3.7168 4.2168 4.7168 5.2168 5.7168 6.2168
Because the final point will not be 2*pi. So expect to see some artifacts of that at some point in time if you do this sort of thing often. Instead, learn to use linspace.
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!