在MATLAB中小数到小数 [英] Fraction to decimal in MATLAB
问题描述
如何在MATLAB中将小数转换为十进制数?
How can I convert a fractional number into decimal number in MATLAB?
我已经在MATLAB中编写了一些程序.但是在迭代过程中,它以分数形式给出所有数字,但我需要以十进制形式给出所有数字.
I have written some program in MATLAB. But in the iterative process it gives all the number in fraction form but I need all the number in decimal form.
请帮助.
推荐答案
要以数字格式显示符号变量,只需在其上调用double函数(或其他任何数字转换函数,例如int).例如,
To display symbolic variables in numerical format, just call the double function (or any other numerical casting function like int) on them. For example,
syms x;
% ...
double(x)
请注意,如果变量是符号表达式,则使用double无效.在这种情况下,您可以使用vpa函数对其进行近似:
Note that if your variable is a symbolic expression, using double won't work. In such situation, you could use the vpa function to approximate it:
syms x;
y = (log(3) * x) + 1;
vpa(y)
这篇关于在MATLAB中小数到小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!