MATLAB四舍五入到最接近的整数

编程入门 行业动态 更新时间:2024-10-27 10:25:05
本文介绍了MATLAB四舍五入到最接近的整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有 1x50000 大小矩阵 v 我希望将其转换为零均值和单位差异:

I have a 1x50000 size matrix v and I want to convert it to zero mean and unit variance:

x = ((v-mean(v))/std2(v));

但是MATLAB没有给出精确的浮点值,而是将其转换为最接近的整数。请帮助我获取确切的值。

But instead of giving me exact floating point values MATLAB is converting it to nearest integers. Please help me in getting the exact values.

推荐答案

检查 v 的数据类型。我确定这是一个整数类型,使用整数运算,这就是为什么结果是整数。您需要将其转换为浮点类型对其执行浮点运算:

Check the data type for v. I'm sure it's an integer type, using integer arithmetic, which is why the result is an integer. You need to convert it to a floating point type to perform floating point operations on it:

v = double(v); % Convert v to a double-precision float x = ((v-mean(v))/std2(v)); % Result is now a double as well

更多推荐

MATLAB四舍五入到最接近的整数

本文发布于:2023-06-08 23:38:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/591037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:整数   最接近   四舍五入   MATLAB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!