Equation for two function curves
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2021년 3월 31일
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
Star Strider
2021년 3월 31일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!