Sorry! , it's my mistake the data file I uploaded had the wrong entries so I uploaded new file with original data
finding a trend line where x axis semilog and y axis linear and trend line follow the eqn y=a*exp(b*x)
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
can you help to find a trend line and the coefficient values for semilox plot
where x- axis == semilog == time axis;
and y-axis == linear == depth axis;
and trend line follow the exponential eqn y = a*exp(b*x)
Risposte (2)
Image Analyst
il 4 Lug 2023
See attached demo for fitting data to exponentials. Adapt as needed.
1 Commento
Image Analyst
il 7 Lug 2023
As we've both said, your attached data is bad. Depth is a constant -- all the same value. Please attach the correct data file. This one is not it!
Star Strider
il 4 Lug 2023
AA straight horizonta line would be the best model, since ‘Depth’ does not change at all over time —
T1 = readtable('data_mat_code.xlsx')
time = T1.time;
Depth = T1.Depth;
VN = T1.Properties.VariableNames;
DepthStats = [min(Depth); max(Depth); std(Depth)]
fcn = @(b,x) b(1).*exp(b(2).*x);
mdl = fitnlm(time,Depth,fcn,rand(2,1))
[y,yci] = predict(mdl, time);
figure
hp1 = semilogx(time, Depth, '.', 'DisplayName','Data');
hold on
hp2 = plot(time, y, '-r', 'DisplayName','Regression');
hp3 = plot(time, yci, '--r', 'DisplayName','95% Confidence Intervals');
hold off
grid
xlabel(VN{1})
ylabel(VN{2})
legend([hp1,hp2,hp3(1)], 'Location','best')
Perhaps this will work better on a different data set.
.
9 Commenti
Star Strider
il 7 Lug 2023
My pleasure!
For the depths < 510, try these —
T1 = readtable('data_mat_code.xlsx', 'VariableNamingRule','preserve')
time = T1.('transit time');
Depth = T1.depth;
Depth_1 = T1.depth_1;
Lv1 = Depth < 510;
Lv2 = Depth_1 < 510;
VN = T1.Properties.VariableNames;
DepthStats = [min(Depth); max(Depth); max(Depth)-min(Depth); std(Depth)]
Depth_1Stats = [min(Depth_1); max(Depth_1); max(Depth_1)-min(Depth_1); std(Depth_1)]
fcn = @(b,x) b(1).*exp(b(2).*x);
% ftns = @(b) norm(Depth - fcn(b,time));
% [B1,fv1,exitflag1,output1] = ga(ftns,2);
% B1
% fv1
% output1.generations
%
% mdl1 = fitnlm(time,Depth,fcn,B1)
% [y,yci] = predict(mdl1, time);
%
% figure
% hp1 = semilogx(time, Depth, '.', 'DisplayName','Data');
% hold on
% hp2 = plot(time, y, '-r', 'DisplayName','Regression');
% hp3 = plot(time, yci, '--r', 'DisplayName','95% Confidence Intervals');
% hold off
% grid
% title('All Data')
% xlabel(VN{3})
% ylabel(VN{1})
% legend([hp1,hp2,hp3(1)], 'Location','best')
%
% ftns = @(b) norm(Depth_1 - fcn(b,time));
% [B2,fv2,exitflag2,output2] = ga(ftns,2);
% B2
% fv2
% output2.generations
%
% mdl2 = fitnlm(time,Depth_1,fcn,B2)
% [y,yci] = predict(mdl2, time);
%
% figure
% hp1 = semilogx(time, Depth_1, '.', 'DisplayName','Data');
% hold on
% hp2 = plot(time, y, '-r', 'DisplayName','Regression');
% hp3 = plot(time, yci, '--r', 'DisplayName','95% Confidence Intervals');
% hold off
% grid
% title('All Data')
% xlabel(VN{3})
% ylabel(strrep(VN{2},'_','\_'))
% legend([hp1,hp2,hp3(1)], 'Location','best')
ftns = @(b) norm(Depth(Lv1) - fcn(b,time(Lv1)));
[B3,fv3,exitflag3,output3] = ga(ftns,2);
B3
fv3
output3.generations
mdl3 = fitnlm(time(Lv1),Depth(Lv1),fcn,B3)
[y,yci] = predict(mdl3, time(Lv1));
figure
hp1 = semilogx(time(Lv1), Depth(Lv1), '.', 'DisplayName','Data');
hold on
hp2 = plot(time(Lv1), y, '-r', 'DisplayName','Regression');
hp3 = plot(time(Lv1), yci, '--r', 'DisplayName','95% Confidence Intervals');
hold off
grid
xlabel(VN{3})
ylabel(VN{1})
title('Depth < 510')
legend([hp1,hp2,hp3(1)], 'Location','best')
ftns = @(b) norm(Depth_1(Lv2) - fcn(b,time(Lv2)));
[B4,fv4,exitflag4,output4] = ga(ftns,2);
B4
fv4
output4.generations
mdl4 = fitnlm(time(Lv2),Depth_1(Lv2),fcn,B4)
[y,yci] = predict(mdl4, time(Lv2));
figure
hp1 = semilogx(time(Lv2), Depth_1(Lv2), '.', 'DisplayName','Data');
hold on
hp2 = plot(time(Lv2), y, '-r', 'DisplayName','Regression');
hp3 = plot(time(Lv2), yci, '--r', 'DisplayName','95% Confidence Intervals');
hold off
grid
title('Depth\_1 < 510')
xlabel(VN{3})
ylabel(strrep(VN{2},'_','\_'))
legend([hp1,hp2,hp3(1)], 'Location','best')
That is the best I can do with these data.
(The ‘All Data’ regressions are in the earlier series, and since it is very difficult to get all of these working in the same run, I am only calculating and plotting the ‘Depth < 510’ and ‘Depth_1 < 510’ regressions here.
.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!