Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Em
Em am 27 Feb. 2022
Kommentiert: Voss am 27 Feb. 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!

Akzeptierte Antwort

Voss
Voss am 27 Feb. 2022
Bearbeitet: Voss am 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');
  3 Kommentare

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by