Make polyfit instead of plot

Hi,
id like to make this into a polyfit instead of a plot.
% Plotting of FRF
fig = figure(1000+p);p=p+1;
set(fig, 'WindowStyle', 'docked');
set(gcf,'color','w');
subplot(3,1,1);
if HOLD
hold on;
end
plot(f,abs(FRF), color, 'linewidth', 2);
ylim([0 1.5]);
xlim([0,f_range]);
grid on;box on;
ylabel('Speed/Speed*');

4 Kommentare

Geoff Hayes
Geoff Hayes am 2 Sep. 2022
@Zakir Mahmood - does it make sense to use polyfit? What would n be?
rockstar49
rockstar49 am 2 Sep. 2022
hey im not sure what n would be in this case.
dpb
dpb am 2 Sep. 2022
What in the world is FRF??? Does the plot bear any relationship to a polynomial of some degree?
With zero useful information, pretty-much at a loss here...
Star Strider
Star Strider am 2 Sep. 2022
@Zakir Mahmood — What result do you want?
@dpb — Probably: Frequency Response Function.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 2 Sep. 2022

0 Stimmen

polynomial_degree = 3; %adjust as appropriate
p = polyfit(f, abs(FRF), polynomial_degree);
fig = figure(1000+p);p=p+1;
set(fig, 'WindowStyle', 'docked');
set(gcf,'color','w');
subplot(3,1,1);
if HOLD
hold on;
end
plot(f,abs(FRF), color, 'linewidth', 2, 'DisplayName', 'abs(FRF)');
y = polyval(p, f);
oldhold = hold('on');
plot(f, y, 'b', 'Linewidth', 2, 'DisplayName', 'fitted abs(FRF)');
hold(oldhold)
ylim([0 1.5]);
xlim([0,f_range]);
grid on;box on;
ylabel('Speed/Speed*');
legend show

Kategorien

Produkte

Version

R2020a

Gefragt:

am 2 Sep. 2022

Beantwortet:

am 2 Sep. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by