Equation for two function curves
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Kenneth Bisgaard Cristensen
il 31 Mar 2021
Commentato: Star Strider
il 31 Mar 2021
Hi MATLAB Community,
How do I create a y using the two diffrent numbers of a,b,c,d to get two function curves. Is there anyway for the y equation to use both data sets?
Any advice would be greatly appriciated.
% DBT Curve using Tanh
a = [95.80266, 46.83612];
b = [-88.53938, 40.09957];
c = [30.84839, 10.91162];
d = [-16.56475, 33.07311];
x = linspace(-200, 150, 200);
y = arrayfun(a+b*tanh((x+c)/d));
figure;
plot(x,y);
legend('L-T', 'T-L');
legend('Location','northwest');
title('DBT Curve');
xlabel('Temperature [°C]');
ylabel('Absorved Energy [J]');
grid on;
grid minor;
0 Commenti
Risposta accettata
Star Strider
il 31 Mar 2021
Try this:
a = [95.80266, 46.83612];
b = [-88.53938, 40.09957];
c = [30.84839, 10.91162];
d = [-16.56475, 33.07311];
x = linspace(-200, 150, 200);
for k = 1:numel(a)
y(k,:) = a(k)+b(k)*tanh((x+c(k))/d(k));
end
figure
plot(x, y)
grid
An explicit loop is more efficient than arrayfun.
2 Commenti
Star Strider
il 31 Mar 2021
As always, my pleasure!
I was also thinking about the ± variables in your previous Question. One option would be to do something similar to what I did here, however using the parameters with what are probably the confidence intervals added and subtracted from each parameter, so the loop would repeat 16 times, once each with various combinations of the parameters with the conficence limits added or subtracted, varying one at a time and leaving the other original parameters unchanged. Then, since the result will be a matrix of row vectors, take the minimum and maximum of the matrix (along dimension 1, the row dimension) and plot those results as a function of ‘x’. Those should be the limits. That is not the most elegant solution, however it is reasonably straightforward and should give you some idea of the limits of the function with the parameter confidence intervals included.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!