フィルターのクリア

how to draw best fit line?

2 ビュー (過去 30 日間)
Amr Hashem
Amr Hashem 2015 年 9 月 18 日
編集済み: Amr Hashem 2015 年 9 月 19 日
I use :
F=[200000;250000;270000];
G=[8000;12000;13000];
figure
plot(F, G, 'go')
hold on;
coeffsss = polyfit(F, G, 1);
fittedXxx = linspace(min(F), max(F), 200);
fittedYyy = polyval(coeffsss, fittedXxx);
plot(fittedXxx, fittedYyy, 'r-', 'LineWidth', 1);
but the line was not completed
I want the line to start from the the beginning/above of the first point.
how I can do this?
  2 件のコメント
Image Analyst
Image Analyst 2015 年 9 月 19 日
The line DOES start above the first point.
Amr Hashem
Amr Hashem 2015 年 9 月 19 日
that's what I guess ... thanks

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2015 年 9 月 19 日
Perhaps you want to go from xlim(1) to xlim(2):
clear; % Erase all existing variables. Or clearvars if you want.
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
F=[264099;279945;297302];
G=[9723;14952;14462];
plot(F, G, 'bo', 'LineWidth', 2, 'MarkerSize', 10)
xlabel('F', 'FontSize', fontSize);
ylabel('G', 'FontSize', fontSize);
grid on;
hold on;
coefficients = polyfit(F, G, 1);
xLimits = xlim
fittedX = linspace(xLimits(1), xLimits(2), 200);
fittedY = polyval(coefficients, fittedX);
plot(fittedX, fittedY, 'r-', 'LineWidth', 3);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
  1 件のコメント
Amr Hashem
Amr Hashem 2015 年 9 月 19 日
thanks that's close to what i want

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by