Plotting Complex Functions in MATLAB: Understanding Period Placement

In summary, the conversation was about using periods in front of operators when working with matrices in MATLAB. The original code was provided and the issue of where to place the periods was discussed. It was suggested to replace every * and / with .* and ./ in order to perform element-by-element operations. The conversation also mentioned the use of the built-in function "vectorize" for certain expressions. The conversation ended with the acknowledgement that the person is new to MATLAB but has heard of vectorize and is grateful for the help.
  • #1
dillonmhudson
49
0
Matrix "." Help in MATLAB

Here is my code:

f=linspace(0,1000,1000);
xf=abs((1-exp(1-2*pi*f.*1i))/(2*pi*f.*1i-1)+(((exp(4*pi*f.*1i)-1)*exp(1-6*pi*f.*1i))/(2*pi*f.*1i))+(((2*pi*f.*1i-1)*exp(1-6*pi*f.*1i)+exp(1-10*1i*f.*pi))/(8*pi^2*f.^2*1i)));
func=plot(f,xf)

I just need to know where the periods need to go, I don't get what I'm doing wrong.

TIA
 
Physics news on Phys.org
  • #2


Use periods in front of operators where one of the operands is a matrix if you want an element-by-element operation. It would probably be easiest just to replace every * and / with .* and ./
 
  • #3


Great! Got it working, thanks for the help!
 
  • #4


No problem.

When you aren't wanting to do matrix calcs, make sure to use element-by-element operators otherwise MATLAB will throw errors when trying to multiply matrices with incompatible dimensions.

There's also a built-in function that will do this for certain expressions called http://www.mathworks.com/help/techdoc/ref/vectorize.html".
 
Last edited by a moderator:
  • #5


Ok, quite the noob with MATLAB right now. I have heard of vectorize though! Thanks :cool:
 

1. What is the purpose of Matrix Help in MATLAB?

The purpose of Matrix Help in MATLAB is to provide assistance and guidance for working with matrices, which are a fundamental data structure in MATLAB. It includes functions and tools for creating, manipulating, and performing operations on matrices.

2. How do I access Matrix Help in MATLAB?

To access Matrix Help in MATLAB, you can use the "help" command followed by the name of the specific matrix function or operation you need help with. You can also access it through the "Help" menu in the MATLAB interface.

3. Can I customize the Matrix Help in MATLAB?

Yes, you can customize the Matrix Help in MATLAB to suit your preferences. You can change the font size, color, and style of the help text, as well as the layout and organization of the help window.

4. How can I learn more about matrices in MATLAB?

To learn more about matrices in MATLAB, you can use the "doc" command followed by the name of the specific matrix function or operation you want to learn about. You can also refer to the official MATLAB documentation or take online tutorials and courses.

5. Is there a limit to the size of matrices in MATLAB?

Yes, there is a limit to the size of matrices in MATLAB. The maximum size of a matrix depends on the amount of memory available on your computer. You can check the maximum size allowed by using the "memory" command in MATLAB.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
572
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top