Troubleshooting Mathematica Plotting Problem

In summary, the student is having trouble generating a graph using a piecewise equation in Mathematica. They have proofread their input and cannot find any errors. Another user suggests using Cos/Sin instead of cos/sin for function names and using square brackets instead of round brackets in functions. The student thanks both users and confirms that their graph was successfully generated after making these modifications.
  • #1
kevmac
6
2

Homework Statement


I've entered the following piecewise equation into Mathematica:

Plot[Piecewise[{{sin (t), 0 <= t < \[Pi]}, {5 + 5 cos (t) + sin (t), \[Pi] <= t < 4*\[Pi]}, {10 cos (t) + sin (t), 4*\[Pi] <= t}}], {t, 0, 20*\[Pi]}]

But I am getting a blank graph in return. I've proofread my input many times and can't find anything wrong with it. Can anyone help me get a graph generated?

Homework Equations

The Attempt at a Solution

 
Physics news on Phys.org
  • #3
kevmac said:

Homework Statement


I've entered the following piecewise equation into Mathematica:

Plot[Piecewise[{{sin (t), 0 <= t < \[Pi]}, {5 + 5 cos (t) + sin (t), \[Pi] <= t < 4*\[Pi]}, {10 cos (t) + sin (t), 4*\[Pi] <= t}}], {t, 0, 20*\[Pi]}]

But I am getting a blank graph in return. I've proofread my input many times and can't find anything wrong with it. Can anyone help me get a graph generated?

Homework Equations

The Attempt at a Solution


jedishrfu is correct. You should also use square brackets, not round brackets in functions. Sin[t] is the correct syntax. If you make those two modifications, it will work, as shown below.
Screenshot from 2016-02-11 13:35:01.png
 
  • #4
Thanks to both of you! This ended up working just fine and I got the same graph that you did e.bar.goum
 
  • Like
Likes e.bar.goum

FAQ: Troubleshooting Mathematica Plotting Problem

Why is my Mathematica plot not displaying any data?

There could be a few reasons for this. First, make sure that you have entered the correct data into the plot function. Check for any typos or missing brackets. Also, make sure that the data you are plotting is in the correct format for the plot function. Finally, check that the data is not too large or too small to be displayed on the plot.

How can I customize the appearance of my Mathematica plot?

To customize the appearance of your plot, you can use various options within the plot function. For example, you can change the color, style, and thickness of the plot line, add labels and titles, adjust the axes, and more. You can also use the "PlotStyle" option to specify a specific style for your plot.

My Mathematica plot is too crowded. How can I adjust the spacing between data points?

You can use the "PlotRangePadding" option to adjust the spacing between data points on your plot. This allows you to add more white space around the plot, making it less crowded. You can also use the "PlotRange" option to specify the range of values to be displayed on the plot, which can help with spacing as well.

How can I add multiple plots to the same graph in Mathematica?

To add multiple plots to the same graph, you can use the "Show" function. This allows you to combine multiple plots into one by specifying them as arguments within the function. You can also use the "Epilog" option to add additional graphics or annotations to your plot.

My Mathematica plot is not showing the desired range on the axes. How can I adjust this?

You can use the "PlotRange" option to specify the desired range on the axes. This allows you to adjust the minimum and maximum values that are displayed on the x and y axes. You can also use the "AxesOrigin" option to specify the point where the axes intersect on the plot.

Similar threads

Replies
1
Views
730
Replies
1
Views
808
Replies
2
Views
691
Replies
2
Views
1K
Replies
4
Views
4K
Replies
4
Views
2K
Replies
2
Views
1K
Replies
1
Views
2K
Back
Top