can anyone help please as i m trying to force a zero intercept for this figure using polyfit

38 views (last 30 days)
x2 = [383.3 306.83 258.66 210.49 152.89 104.72 48.17];
y2 = [1.09 0.89 0.78 0.61 0.45 0.3 0.17];
plot(x2,y2,'ro');hold on; grid on; xlim([0 420]); ylim([0 2]);
xlabel('Rotor speed,\omega_{R} (rad/s) ');
ylabel('Inverse precession speed,1/\omega_{P} (s/rad)');
title('Curve of angular speed against inverse precession on angular speed');
p = polyfit(x2,y2,1);
pp = polyval(p,x2);
hold on
plot(x2,pp,'-r');

Answers (1)

Star Strider
Star Strider on 20 Nov 2015
The polyfit function will not let you force a zero intercept, but the mldivide operator (\) will:
x2 = [383.3 306.83 258.66 210.49 152.89 104.72 48.17];
y2 = [1.09 0.89 0.78 0.61 0.45 0.3 0.17];
p = x2(:)\y2(:); % Calculate Slope, Forcing Zero Intercept
p =
2.9039e-003
In the context of your code:
x2 = [383.3 306.83 258.66 210.49 152.89 104.72 48.17];
y2 = [1.09 0.89 0.78 0.61 0.45 0.3 0.17];
plot(x2,y2,'ro');hold on; grid on; xlim([0 420]); ylim([0 2]);
xlabel('Rotor speed,\omega_{R} (rad/s) ');
ylabel('Inverse precession speed,1/\omega_{P} (s/rad)');
title('Curve of angular speed against inverse precession on angular speed');
p = x2(:)\y2(:); % Calculate Slope, Forcing Zero Intercept
pp = p*x2;
hold on
plot(x2,pp,'-r');

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!