How can I create a smooth curve that fits my data ?

6 views (last 30 days)
Marie Robert on 24 Apr 2018
Commented: Kh zaa on 16 Sep 2018
Hello everyone,
I am currently trying to figure out a way to create a curve that would fit my data, not using the "plot" function. I have seen that there are filters that exist and tried the "sgolay" one but it won't work (probably because I don't quite understand how it works). I would appreciate some help.
Here is the current code:
set(0,'defaulttextinterpreter','latex')
clf
%plot(alpha1,F_z1,'*')
hold on
barplotxy(alpha1,F_z1,lalpha1,delta_fz1);
barplotxy(alpha2,F_z2,lalpha2,delta_fz2);
barplotxy(alpha3,F_z3,lalpha3,delta_fz3);
barplotxy(alpha4,F_z4,lalpha4,delta_fz4);
h=sgolayfilt(alpha4, 4, 7)
title('Variation de la portance $F_z$ en fonction de l''angle d''incidence $\alpha$')
ylabel('Force $F_z$ de portance [N]');
xlabel('Angle d''incidence $\alpha$ de l''\''ecoulement [rad]');
axis([-0.5 1 0 1.62])
and the previous version of the graph:
The smooth curve would fit the blue data (instead of a linear fit).
PS: I am French and I struggle with very specific terms (and Matlab in general) so it would d be really nice if you used the simplest terms possible.

Show 1 older comment
Marie Robert on 24 Apr 2018
Sure, here it is
Stephan on 24 Apr 2018

Si vous avez la boîte à outils d'ajustement de courbe, utilisez-la.

Si ce n'est pas le cas, ce lien peut vous aider ici. Vous pouvez également faire traduire la documentation de Matlab en français - cela fonctionne plutôt bien. Cliquez sur le bouton "Traduire cette page" dans le coin supérieur droit et sélectionnez la langue appropriée. Dans votre cas probablement français ;-)

En attendant, je vais regarder vos données.

Bonne chance Si vous avez d'autres questions, s'il vous plaît contactez-nous.

Salutations Stephan

Marie Robert on 24 Apr 2018
Thank you for your help! I did succeed at fitting my data. However, I have a new problem: when I plot the fittedmodel ( plot(fittedmodel1,F_z4,alpha4) ), a part of it is cropped in my figure window. How can I solve this ?

Stephan on 24 Apr 2018
Edited: Stephan on 24 Apr 2018
Hi,
thats nice so far. You did it with the curve fitting toolbox i guess (?)
Try the xlim command after the plot command for your fitted curve:
xlim([-0.5,1])
The interval of -0.5...1 is just taken from your diagramm - you can of course use the variables of your .mat files data for adjusting this.
I hope it works well for you. If you still have problems please share your code.
best regards
Stephan

Marie Robert on 24 Apr 2018
At last, I did succeed at doing what I wanted to do. Thank you very much for your help!
Stephan on 24 Apr 2018
c'était un plaisir!
Kh zaa on 16 Sep 2018
I use level-1 s-function in my simulink model. Measurements of 5 variables are collected in simulink and sent to s-function. In order to filter out some of measurements noise, i need to use the average of the snapshots received over a a time window (i.e. 2 second). how i can do that ? thanks