Curve fitting from the tools menu
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
First things first sorry for not translating my comments in the code (but if need be i will do so ) .
Everything is functional ,i retrieved the polynomial ecuation from the tools menu ,what i'm interested in finding out is if it's possible to get to keep the polynomial ecuations on the..figure window for all the 4 plots at the same time not one at a time using the tools method .
And i'd also like to know if there's another way of obtaining the polynomial ecuation/s from the graphs themselves .
Also...please ignore the xlabel,ylabel i know they're nok.
%% Apps_MEIM2
%% date de intrare app1
p_at=1;% presiunea atmosferica
D=5; %Ø
d=0.1; %Ø
n=0.85; %randamentul mecanic al transmisiei
Ps=[2;2.4;2.8;3.2;3.6;4;4.4]; % suprapresiunea
%% date de intrare app2
I=[10;12;13;14;16;19;22;23]; % Indicatiile manometrului etalon
In=[11;13;15;17;19;20;22;24];% Indicatiile manometrului de masura
%% date de intrare app3
h=[0.005;0.01;0.015;0.02;0.025;0.03;0.035;0.04];
R=0.050;
h0=[0.085;0.08;0.075;0.07;0.065;0.06;0.055;0.05];
H1=0.2;
g=9.81;
%% Bloc de calcul app1
ps=n*Ps*(D/d)^2;
% presiunea absoluta sporita
P=p_at+ps;
%% Bloc de calcul app2
% eroarea absoluta a etalonarii delta_l
delta_l=In-I;
% eroarea relativa e
e=(delta_l./In)*100;
%%Bloc de calcul app3 (viteze unghiulare)
% viteza unghiulara la iesirea din rezervor vu1
vu1=2/R*sqrt(g*(H1-h0));
% viteza unghiulara la fundul rezervorului vu2
vu2=2/R*sqrt(g*h0);
%
vu=sqrt((h*g.*(h0-h))./R.^2);
%% Bloc Grafic
figure
subplot(2,2,1);plot(P,ps);grid on ;axis tight;title('presiunea absoluta sporita in functie de suprapresiune');
xlabel('Presiunea Sporita Ps[at]');ylabel('Presiunea absoluta[at]');legend('f(Ps)');
subplot(2,2,2);plot(In,e);grid on;axis tight;title('Indicatiile manometrului In in functie de eroarea realtiva e');
xlabel('valorile manometrului de masura In [N/m^2]');ylabel('eroarea relativa e [%]');legend('f(In)');
subplot(2,2,3);plot(vu,h);grid on;axis tight;title('viteza unghiulara in functie de h');
ylabel('h [m]');xlabel('vu [1/s]');legend('f(h)');
subplot(2,2,4);plot(vu,h0);grid on;axis tight;title('viteza unghilara in functie de h0');
ylabel('h0 [m]');xlabel('vu [1/s]');legend('f(h0)');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/903495/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/903500/image.png)
0 comentarios
Respuestas (1)
Milan Bansal
el 29 de Sept. de 2023
Hi,
As per my understanding you want to know how to plot the polynomial equations for all the plots in the figure simultaneously without using the "tool" menu in figure window. Also, you want to know how to extract the polynomial equation from the plot.
Extract the coefficients of the fitted polynomial equation using "polyfit" function as shown in the code below.
coeffe = polyfit(In,e,6);
Refer to the documentation link to learn more about "polyfit" function.'
Then use the "polyval" function to generate the fitted curve.
xIn = linspace(In(1),In(end),100); % time steps to plot the smooth curve
polye = polyval(coeffe,xIn);
Refer to the documentation link to learn more about "polyval" function.'
Plot the generated polynomial in the corresponding subplot.
subplot(2,2,2);plot(In,e); hold on;
plot(xIn,polye); hold off;
grid on;axis tight;
title('Indicatiile manometrului In in functie de eroarea realtiva e');
xlabel('valorile manometrului de masura In [N/m^2]');
ylabel('eroarea relativa e [%]');
legend('f(In)');
Follow the same steps for all the four plots.
Use the "poly2sym" function to extract the equation in symbolic form and use and "pretty" function to display the equation. Refer to the code below.
eqn_e = poly2sym(coeffe)
pretty(eqn_e)
Refer to the documentation to learn more about "poly2sym" function.
Refer to the documentation to learn more about "pretty" function.
Hope it helps!
0 comentarios
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!