MATLAB Need help with integration and plotting

In summary, the speaker is asking for help with integrating an equation and plotting the result using MATLAB. They have an equation of the form dy = (1/x)dx and have tried using the int function but are unsure of how to plot y as a function of x. They also mention trying a different equation, (1/y)dy = dx, but still need help plotting the result.
  • #1
sarrfriend
6
0
Hi,
I have been trying to integrate an equation and then plot the result using MATLAB but haven't figured out how to do it. Say, I have an equation of the form dy = (1/x)dx. I want to integrate the above equation and then plot y as a function of x. So, to integrate I do this:

syms y x
LHS = int(1,y);
RHS = int(1/x,x);

So, now LHS and RHS contain the corresponding results of the integrals. How do I plot y as a function of x?

Thanks in advance.

Sarrvesh
 
Physics news on Phys.org
  • #2
It would be better if you could use the following equation instead of the one written above: (1/y)dy = dx. Now, how do I plot y as a function of x after integrating?
 

What is MATLAB?

MATLAB is a programming language and numerical computing environment that is commonly used in scientific and engineering applications. It allows users to perform complex mathematical operations, create visualizations, and analyze data.

How do I integrate in MATLAB?

To integrate in MATLAB, you can use the "integrate" function. This function takes in an expression and the variable you want to integrate with respect to. For example, if you want to integrate the function f(x) from 0 to 5, you would use the command "integrate(f, 0, 5)".

What is plotting in MATLAB?

Plotting in MATLAB involves creating visual representations of data or mathematical functions. This can be done using the "plot" function, which takes in the x and y coordinates of the data points and displays them on a graph.

How do I plot multiple functions in MATLAB?

To plot multiple functions in MATLAB, you can use the "hold" function. This allows you to plot multiple functions on the same graph by preventing the previous function from being cleared. You can also use the "subplot" function to create multiple plots within the same figure.

Can I customize the appearance of my plot in MATLAB?

Yes, you can customize the appearance of your plot in MATLAB using various functions such as "title", "xlabel", "ylabel", and "legend". You can also change the color, style, and size of the plot using the "color", "linestyle", and "linewidth" properties. Additionally, you can save your plot as an image or export it in different file formats.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
985
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
801
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top