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

  • Thread starter Thread starter Jamin2112
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
The discussion revolves around creating a program that calculates a user's position on a bell curve based on their height and weight. The user encounters an error in their code related to matrix operations, specifically that "inputs must be a scalar and a square matrix." The solution involves using element-wise operations in MATLAB, such as the ".*" operator for multiplication and ".^" for exponentiation, to ensure that the vectors for input and output maintain the same dimensions. Additionally, there is a request for guidance on plotting a graphic that illustrates the shaded area under the curve to the left of the user's percentile mark, indicating a need for visual representation of the 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.
 
Back
Top