How to know which plot is more linear then the other?

Illustration
Quincy - 2020-12-28T12:43:05+00:00
Question: How to know which plot is more linear then the other?

Dear all, I have two datasets arrays:   A = [0 0.423891532 0.819380304 1.289479809 1.739548357 2.288748183 2.8990623 3.618974647 4.402757506 5.268816221 6.240886445 7.278958674 8.321358342 9.369407383 10.37825178 11.17417756 12.02774088 12.69808163 13.49653247 14.36958724 15.50198578 16.68295148 20.09421834] %% B = [0 0.406558949 0.771247013 1.123943155 1.487752056 1.915016538 2.365427777 2.852526752 3.419995212 3.933726314 4.436914792 4.958793052 5.510476759 5.961517074 6.415268974 6.843890692 7.102927349 7.118216122 7.677116245 8.751585797 9.636923065 10.32502819 12.9488068] %% plot(A, 'green') hold on plot(B, 'blue') hold off %% Both A and B are nonlinear curves, but B seems to be more linear (less curvature) than A. How can I show such information numerically?  

Expert Answer

Profile picture of Kshitij Singh Kshitij Singh answered . 2025-11-20

You can see the residual error with linear fit to see which dataset is more linear

 

[~, eA] = polyfit(1:numel(A), A, 1)
[~, eB] = polyfit(1:numel(B), B, 1)

Result

>> eA.normr
ans =
    4.0713
>> eB.normr
ans =
    2.8868

Vector 'B' is more linear as compared to A.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!