using MATLAB for space link
1 次查看(过去 30 天)
显示 更早的评论
Hello all. I want to convert an output signal that I got from an input multiplied by a transfer function to double precision. I don't want to use fplot in this case. Is there a way to get my output signal into double precsion before I can then simply plot it? A piece of my code is below for a better idea. The outputs I need to convert to double precision are y1 and y2 as they are currently in synbolic. I'd appreciate any help.
%%Input singal at frequency F1Hz
x1 = sin(2*pi*F1Hz*t);
X1s = laplace(x1);
Y1s = X1s*H1(s);
y1 = ilaplace(Y1s);
%%Input single regular
x2 = sin(t);
X2s = laplace(x2);
Y2s = X2s*H1(s);
y2 = ilaplace(Y2s);
2 个评论
回答(2 个)
Star Strider
2021-10-28
It depends whether they contain symbolic variables or if they are functions (and I can’t determine that from the code snippet). If they can be evaluated as functions, then plotting them would require that tney be converted to anonymous function first using the matlabFunction function, and then evaluated. If they are already vectors only of symbolic numbers, use the double function to convert them.
.
0 个评论
Walter Roberson
2021-10-28
Your ilaplace() functions are going to be in terms of t at least, and possibly other symbolic variables as well.
If you have a symbolic expression of one variable, then there are several ways to proceed:
- use fplot() to plot the expression. This is easy, but you do not really have access to the computation results afterwards
- subs() numeric values in for the symbolic variables and double() the result; then plot()
- use matlabFunction() on the symbolic expression, and call the function on the numeric vector.
However... ilaplace() results are sometimes not very clean. In some cases, none of these approaches will work. In other cases, using matlabFunction() will give you problems unless you use arrayfun() to process one time value per call.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!