Strange function fit to data points- sorting by first column vals?

1 vue (au cours des 30 derniers jours)
Em
Em le 27 Fév 2022
Commenté : Voss le 27 Fév 2022
Hi,
does anyone have any idea why my function has such a strange shape? In the modelling app I'm not getting this.
I think I need to sort the T values keeping the rows together maybe but is there a way to keep columns together and sort by the first column vals?
conductivity4=abs(set4(:,2));
scatter(set4(:,1),conductivity4)
T4=set4(:,1);
hold on
y=(1.236*10^(-12))*exp(0.01189.*T4)
plot(T4,y)
ylim([1 2.2]*10^(-11))
xlim([180 240])
Thanks!

Réponse acceptée

Voss
Voss le 27 Fév 2022
Modifié(e) : Voss le 27 Fév 2022
I think it is the points not being in monotonic order in T4, and sorting them first will fix it, like you say.
% T4 values to use, in order:
T4_order = 180:240;
% create a random permutation of those values:
T4 = T4_order(randperm(numel(T4_order)));
% calculate the corresponding y values:
y=(1.236*10^(-12))*exp(0.01189.*T4);
% plot (should have the same problem as your plot):
figure();
plot(T4,y,'r');
% sort the T4:
T4 = sort(T4);
% calculate the corresponding y values:
y=(1.236*10^(-12))*exp(0.01189.*T4);
% plot (should be good):
figure();
plot(T4,y,'r');
  3 commentaires
Em
Em le 27 Fév 2022
This is great!
Voss
Voss le 27 Fév 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by