Linear fit line for multiple Y-axis
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Syed Hussain
el 7 de Jul. de 2020
Respondida: dpb
el 8 de Jul. de 2020
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.)

0 comentarios
Respuesta aceptada
dpb
el 8 de Jul. de 2020
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!