필터 지우기
필터 지우기

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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by