Creating a Bell Curve Program in MATLAB: Troubleshooting and Adding Graphics

  • MATLAB
  • Thread starter Jamin2112
  • Start date
  • Tags
    Matlab
In summary, the conversation is about using a software package and an introduction book to create a program that takes in a user's height and weight and shows their place on a bell curve. The discussion also includes troubleshooting an error and plotting a graphic to show a shaded area under the curve. The solution involves using piecewise operations and the .^ operator for element-by-element exponentiation.
  • #1
Jamin2112
986
12
So I've been just screwing around and having fun with this newfound software package and the introduction book that I bought at the bookstore. I decided to make a program that takes in a user's height and weight, then shows their place on a bell curve.

Here's what I have so far:


screen-capture-1-16.png








First help me figure out the error. Basically it doesn't like row 28 because "inputs must be a scalar and a square matrix."

Then help me figure out how to plot a graphic that shows a shaded area under the curve to the left of the user's percentile mark.


Thanks in advance!
 
Physics news on Phys.org
  • #2
Jamin2112 said:
So I've been just screwing around and having fun with this newfound software package and the introduction book that I bought at the bookstore. I decided to make a program that takes in a user's height and weight, then shows their place on a bell curve.

Here's what I have so far:

screen-capture-1-16.png


First help me figure out the error. Basically it doesn't like row 28 because "inputs must be a scalar and a square matrix."

Then help me figure out how to plot a graphic that shows a shaded area under the curve to the left of the user's percentile mark.

Thanks in advance!

MATLAB treats objects as matrices. Let's say you assign the result of v^2 to another object. If v is not a square matrix, it will throw an output error.

It seems what you want to do is use the element at a given index and output your final value in the output vector at the same index.

So instead of using say v^2 you would use v.*v. Look up the help section and look for piecewise operations that have ".*" or "./" or something with a dot, and that should output another vector where the index of the output corresponds with the one-dimensional real function given the input that was obtained by your input vector.

So you should end up with two vectors, one with input (x) and one with output (y), both with same dimensions which is what you want.
 
  • #3
Use the .^ operator for element-by-element exponentiation.
 

Related to Creating a Bell Curve Program in MATLAB: Troubleshooting and Adding Graphics

1. How do I troubleshoot errors in my Bell Curve program in MATLAB?

To troubleshoot errors in your Bell Curve program, you can use the built-in debugging tools in MATLAB such as the "dbstop" command to stop at specific lines of code and examine the values of variables. You can also use the "try-catch" statement to handle errors and display helpful messages to identify the source of the error. Additionally, checking your syntax and ensuring that all variables are properly defined can also help to troubleshoot errors.

2. How can I add graphics or visualizations to my Bell Curve program in MATLAB?

To add graphics or visualizations to your Bell Curve program, you can use the "plot" or "scatter" commands to create a graph of your data. You can also customize the appearance of the graph by changing the colors, labels, and axis limits. Additionally, you can use the "histogram" command to create a histogram of your data, which can be useful for visualizing the distribution of your data on the Bell Curve.

3. Can I customize the shape and parameters of the Bell Curve in my program?

Yes, you can customize the shape and parameters of the Bell Curve in your program by using the "normpdf" function. This function allows you to specify the mean and standard deviation of the Bell Curve, which will in turn affect the shape and location of the curve on the graph. You can also use the "normcdf" function to calculate the probability of certain values falling within a specific range on the Bell Curve.

4. How do I handle missing or incomplete data in my Bell Curve program?

To handle missing or incomplete data in your Bell Curve program, you can use the "isnan" function to check for any missing values in your data set. You can then use the "if" statement to skip over those values or replace them with a placeholder value. Additionally, you can use the "fillmissing" function to replace missing values with the mean, median, or a specified value.

5. Can I export the results of my Bell Curve program in MATLAB to another file format?

Yes, you can export the results of your Bell Curve program in MATLAB to another file format such as a CSV or Excel file. You can use the "writematrix" or "writecell" functions to write your data to a file, which can then be opened and manipulated in other programs. You can also use the "save" function to save your workspace variables as a .mat file, which can be loaded back into MATLAB for further analysis or visualization.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
9K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
12K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Special and General Relativity
Replies
1
Views
2K
Back
Top