# Curve fitting from the tools menu

4 ビュー (過去 30 日間)
Opariuc Andrei 2022 年 2 月 22 日

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)');

サインインしてコメントする。

### 回答 (1 件)

Milan Bansal 2023 年 9 月 29 日
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);
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);
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)
Hope it helps!

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by