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

  • Context: MATLAB 
  • Thread starter Thread starter Jamin2112
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion focuses on troubleshooting a MATLAB program designed to display a user's height and weight on a bell curve. The primary issue arises from an error indicating that "inputs must be a scalar and a square matrix," specifically at row 28 of the code. To resolve this, the user is advised to utilize element-wise operations in MATLAB, such as the ".*" operator for multiplication and ".^" for exponentiation, ensuring that both input and output vectors maintain the same dimensions. Additionally, guidance is provided on how to plot a shaded area under the curve to represent the user's percentile.

PREREQUISITES
  • Basic understanding of MATLAB programming
  • Familiarity with matrix operations in MATLAB
  • Knowledge of bell curve statistics
  • Experience with MATLAB plotting functions
NEXT STEPS
  • Learn about MATLAB element-wise operations, specifically ".*" and ".^"
  • Research how to create and customize plots in MATLAB
  • Explore MATLAB functions for statistical analysis and bell curve generation
  • Investigate how to shade areas under curves in MATLAB plots
USEFUL FOR

This discussion is beneficial for MATLAB programmers, data analysts, and anyone interested in statistical visualization techniques, particularly those working with bell curves and user input data.

Jamin2112
Messages
973
Reaction score
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
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.
 
Use the .^ operator for element-by-element exponentiation.
 

Similar threads

Replies
5
Views
9K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K