Matlab,normal curve,third power polynomial - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Matlab,normal curve,third power polynomial

Posts: 2Member
Hello, i'm new with matlab and i have a problem with my code, i got this

y=[70,73,62,67,70,72,67,72,71,73,70,75,66,69,67,72,67,69,71,71,68,74,73,62,65,75,67,64,72,73];
max(y);
min(y);
bins=min(y):max(y);
numel(y);
x=0:1:29;
numel(x);
polyfit(x,y,3);
best_y=(0.0011*x.^3-0.0499*x.^2+0.6198*x+68.0076);
plot(x,best_y);
u=mean(y);
s=std(y);
normal_y=30*((exp((-(x-u).^2)/(2*s.^2)))/(s*(2*3.1416).^(0.5)));
plot(x,best_y,x,normal_y);
my first tried was with the third order polynomial and then i tried it with the second order one. when i got the graph it looked like 2 parallel lines , i know they have to be close. i dont know what is the problem with my code

the curious part is that when i plot the best_y by itself it looks good upside-down parabola) , same with the normal_y which looks like half of the normal curve. but as soon as i plotted them together one is on top semi-curve and the other one is a line at the bottom. is that ok ?

thanks a lot