【问题标题】:changing array dimension and type更改数组维度和类型
【发布时间】:2012-09-09 18:03:21
【问题描述】:

我是 matlab 的新手。 我有一个数组50x100 uint8,我想把它改成5000x1 double。我怎样才能做到这一点? 提前致谢。

【问题讨论】:

    标签: arrays matlab math dimensions


    【解决方案1】:

    如果您只想要一列数据,冒号运算符: 也是一种选择:

     data = uint8(randi(10,50,100));
     result = double(data(:));
    

    【讨论】:

    • @diophantine 在这个问题中,使用reshape 没有任何意义! OP只要求一种将50x100矩阵转换为5000x1矩阵的方法,我的回答解决了!
    【解决方案2】:

    您可以使用reshape(matrix_to_resize, new_row_size, new_col_size) 来调整数组的大小。您应该能够使用结果矩阵和 im2double(matrix) 函数将元素转换为双精度数。

    The documentation for reshape.

    【讨论】:

    • 出现此错误:Undefined function 'resize' for input arguments of type 'double'.
    • 对不起,我的意思是重塑!已编辑。
    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 2018-05-21
    • 2011-07-21
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 2014-08-10
    • 2012-05-27
    相关资源
    最近更新 更多