Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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!

Risposta accettata

Voss
Voss il 27 Feb 2022
Modificato: Voss il 27 Feb 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');

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by