How to transform function in MatLab? Shift, Scale etc.

조회 수: 29 (최근 30일)
ha9981
ha9981 2012년 9월 23일
댓글: Preetha Thanunathan 2020년 4월 7일
If I have a function as follows:
syms x1;
syms t;
x1 = exp(t)* Heaviside(2*t);
How do I do define x2 = x1(t-2) so I can plot it. I would rather not have to redefine the entire function doing the work myself each time I want to do a transformation. Is there a way of achieving this?
  댓글 수: 1
Preetha Thanunathan
Preetha Thanunathan 2020년 4월 7일
I have a function f(x) whose range is the interval [0, 1], and I need to shift it and stretch it so that the range is now the interval [a, b]. Find a function g(x) (defined in terms of f(x)) so that g(x) has an range [a, b].
In Matlab, the rand command produces a random number between 0 and 1, under the uniform distribution; that's different from the normal distribution. The graph of the uniform probability distribution is a horizontal line. The graph of the normal distribution is the bell curve.
I need a program that will accept input values a and b, a < b, and will output a random number between a and b, You'll do this by shifting and stretching the rand function. Notice that in Matlab the rand function doesn't take an input. You just type rand and hit enter, and the program will spit out a random number between 0 and 1.
can anyone answer this question

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

답변 (3개)

ha9981
ha9981 2012년 9월 23일
I think I found it. Appears to work.
x3 = subs(x1, t, t-2)
Is this a correct and reliable way?
  댓글 수: 2
Wayne King
Wayne King 2012년 9월 23일
ahh yes, I forgot about subs!
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 23일
편집: Azzi Abdelmalek 2012년 9월 23일
If you want to delay with t0, compute x(t) then plot(t+t0,x)

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


Wayne King
Wayne King 2012년 9월 23일
편집: Wayne King 2012년 9월 23일
I don't know of a shift operator for symbolic functions.
syms t
tprime = t-2;
x1 = exp(t)*heaviside(2*t);
x2 = exp(tprime)*heaviside(2*tprime);
Or just:
x2 = exp(t-2)*heaviside(2*(t-2));
  댓글 수: 3
Wayne King
Wayne King 2012년 9월 23일
I'm not sure what you mean by recheck your code.
ha9981
ha9981 2012년 9월 23일
You fixed it now. It said xprime before so it wasn't going to work.

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


Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 23일
편집: Azzi Abdelmalek 2012년 9월 23일
syms t x
x1 = exp(t)* heaviside(2*t);
t=0:.1:10
if you want to plot |x1(t-2)| then
y=eval(x1)
t=t+2 % not t=t-2 because it's a delay
close;plot(t,y)
set(gca,'xlim',[0 max(t)])

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by