I have a function which dies of quickely. I need this function to smoothly decay off to 0 . Is there any way in Matlab to make that happen?

댓글 수: 4

Alan Stevens
Alan Stevens 2020년 7월 26일
What's the function?
m(i)=[((-b + (((b*b)-(4*y*a*(T(i)-Tc)))^0.5))/(2*y))^0.5];
For T>Tc m(T) becomes complex so m(T>Tc)=0
Hence I want m(T) to smoothly decay to 0 for T>Tc
Please give values for everything in that alphabet soup. And include a screenshot of what you got, and what you'd like to achieve, but only after you read this link.
T = linspace(-5, 5, 500);
Tc = 3;
y = 2;
a = 7;
b = 6;
m = ((-b + (((b*b)-(4*y*a*(T-Tc))).^0.5))/(2*y)).^0.5;
subplot(2, 1, 1);
plot(T, real(m), 'b-', 'LineWidth', 2);
title('Real(m) vs. T', 'FontSize', 20);
grid on;
xlabel('T', 'FontSize', 20);
ylabel('real(m)', 'FontSize', 20);
% For T>Tc, m(T) becomes complex so m(T>Tc)=0
% Hence I want m(T) to smoothly decay to 0 for T>Tc
subplot(2, 1, 2);
plot(T, imag(m), 'b-', 'LineWidth', 2);
title('Imag(m) vs. T', 'FontSize', 20);
grid on;
xlabel('T', 'FontSize', 20);
ylabel('imag(m)', 'FontSize', 20);
For the random values I chose, it does look like the curve approaches the Tc point smoothly. What does it look like for you, with your values???
Saurav
Saurav 2020년 7월 27일
Sir, curve is smooth till Tc then as per the function it must go to 0 for T>Tc but I want to modify the function in such way that for T>Tc curve smoothly decays to 0 with finite first derrivative for entire range of values

댓글을 달려면 로그인하십시오.

답변 (1개)

Alan Stevens
Alan Stevens 2020년 7월 26일
편집: Alan Stevens 2020년 7월 26일

0 개 추천

How about writing a function like:
function mfn = mvalue(T,Tc,a,b,y)
disc = b^2 - 4*y*a*(T - Tc);
quad = -b + disc^0.5/(2*y);
if disc>0 && quad>0
mfn = quad^0.5;
else
mfn = 0;
end
end
and then calling
m(i) = mvalue(T(i), Tc, a, b, y);

댓글 수: 5

Saurav
Saurav 2020년 7월 26일
SIr, what I need is m(T) smoothly dying out after T=Tc is reached . This doesn't ensure smooth decay with finite slope throughout the range. Thanks in advance
Alan Stevens
Alan Stevens 2020년 7월 26일
The value of m could be complex before T reaches Tc (if quad is negative). The mvalue function simply returns zero whenever it would otherwise have returned a compex number.
Saurav
Saurav 2020년 7월 26일
yes i know that but my question is actually about is there any way to smoothen out abrupt fall to 0 by modifying the actual function in some way to avoid first derrivative becoming infinite for m(T).
Alan Stevens
Alan Stevens 2020년 7월 26일
편집: Alan Stevens 2020년 7월 26일
Impossible to tell without knowing about the system you are modelling. Mathematically you could probably multiply m by some sort of exponential decay term. However, would that make sense in the context of your model?
Saurav
Saurav 2020년 7월 27일
Sir, I want the function to decay to 0 over small range with small change to curve for lets say
( Tc-delta,Tc+delta) range for delta-->0 with ensuring first derrivative remaining finite for entire range.Directly multiplying the function with exponential decay will highly modify the function.I tried adding small expo. decay to this function at the end for T>Tc but it creates knife edge point in the function at T=Tc. All i am asking is there any way to smooth the function in matlab because in verilog it automatically creates smooth function for such discontinuities. Thanks in advance.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2020년 7월 26일

댓글:

2020년 7월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by