Help Plotting Polynomial and Annotating With Data
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Im trying to plot a polynomial function (Non Linear) against an ideal straight line (Linear).
I have managed this with my limited MatLab skills, however i would like to extrapolate some data from the graph which i know can be done as i have done it in the past but cannot work out how to do it again.
I want to determine the maximum non linearity between the two plots and illustrate this on the plot
Below is the code i have so far:
y_1=@(x)+1+2*x+0.05*x.^2-0.00833*x.^3;
x_1=0:6;
figure % new figure window
plot(x_1,y_1(x_1),'--b*')
hold on
x2=0:6;
y2=1+2*x2
plot(x2,y2,'r')
hold off
title('Graph of Sensor Non Linearity')
xlabel('Input Units (I)') % x-axis label
ylabel('Output') % y-axis label
legend('Non Linearity','Ideal Straight Line (ISL)','Location','southeast')
grid on
grid minor
Any help is appreciated
0 comentarios
Respuestas (1)
Star Strider
el 2 de En. de 2015
How do you define ‘maximum non linearity’?
It would seem to me that it would be defined by the square and cubic terms:
d = 0.05*x.^2-0.00833*x.^3
so you might simply determine the maximum of that expression. Taking the derivative and solving it:
0 = 0.1*x - 0.02499*x^2
gives me a value of x=4.002. The value of d is then 0.26688.
Is that what you want?
4 comentarios
Star Strider
el 10 de En. de 2015
If you want to plot it, all you need to do is to add a plot call:
y_1=@(x)+1+2*x+0.05*x.^2-0.00833*x.^3;
y_2 = @(x) 1 + 2.* x;
x = linspace(0,6);
dy = @(x) y_1(x) - y_2(x);
figure(1)
plot(x, dy(x))
grid
xlabel('X')
ylabel('Deviation')
The calculated value ‘dy’ should be the ‘maximum vertical distance’, since the difference ‘dy’ is evaluated at the same values of ‘x’ for both ‘y_1’ and ‘y_2’. The analytic solution (that may differ slightly) will take the maximum of the difference in the two curves, first subtracting one from the other and then doing the evaluation, yielding the maximum absolute distance. The difference is whether you do the subtraction after evaluating the two functions (numeric) or before (analytic).
Ver también
Categorías
Más información sobre Annotations 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!