Linear fit line for multiple Y-axis

2 次查看(过去 30 天)
I need to plot the best fit linear line for multiple y-axis data. I am able to do this with single y-axis but do not know it for multiple y-axes scenario.
(Here is the graph which i want to plot, but the best fit linear line in it, is corresponding to only single y-axis data.)

采纳的回答

dpb
dpb 2020-7-8
You'll get same coefficients if you fit
b=polyfit(t,mean(y,2)); % assume columns are variables, rows, observations
as will by fitting all data by duplicating the time vector for all columns and fitting all observations individually. Statistics will be somewhat different owing to the independent variables, but if all one cares about are the coefficients, the average works and is simpler to code.
x=[1:10].'; % an x-vector
y=rand(10,10); % 10 column vectors to go with x
>> b1=polyfit(x,mean(y,2),1) % fit mean by column
b1 =
0.0178 0.3858
>> b2=polyfit(repmat(x,10,1),y(:),1) % fit all observations individually
b2 =
0.0178 0.3858
>>
As can see, one gets same coefficient array either way -- altho in reality it's not that much more to "do it right".

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by