Get y coordinate for x = 0 from linear trendline

1 回表示 (過去 30 日間)
Marc Jakobi
Marc Jakobi 2013 年 10 月 28 日
回答済み: Marc Jakobi 2013 年 10 月 28 日
Hi. I have a scatter of three coordinates:
%scattered values (y1...4 are numbers between 0 & 1, x1...4 are numbers between 0 & 100)
yVect = [y1, y2, y3, y4];
xVect = [x1, x2, x3];
%scatter plot & trendline
plot = figure;
ST_533 = axes('Parent',plot);
hold(ST_533,'all');
scatter(xVect,yVect,'filled');
ylim([0 1]);
Poly = polyfit(xVect,yVect,1);
x = linspace(0,100,5000);
Trend = polyval(Poly,x);
hold on
plot(x,Trend);
Now I need to find the y-value at which the trendline passes through the y-axes (so when x equals zero). Any Idea how I can do this? I've been searching for quite a while and couldn't find anything so far. Thanks!

採用された回答

Marc Jakobi
Marc Jakobi 2013 年 10 月 28 日
I just figured it out. It won't work for all types of trend lines, but it solves my problem. Since x starts at zero, I can easily find it by typing
A = Trend(1);

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by