![]() |
在Matlab中将单元阵列的部分与因子相乘
我想在Matlab中乘以单元数组的一部分(请参见下面的示例)。
my_cell1 = {'a', 'b', 'c'; 'd', '1', '2'; 'e', '3', '4'}; % Looks like: % abc % d 1 2 % e 3 4 my_cell2 = my_cell1; my_cell2(2:3, 2:3) = num2cell(str2double(my_cell2(2:3, 2:3)) * 2); %Multiply the numbers by factor 2 my_cell3 = {'a', 'b', 'c'; 'd', '2', '4'; 'e', '6', '8'}; isequal(my_cell2, my_cell3) %False 显然, my_cell2不等于my_cell3 。似乎是这种情况,因为my_cell2中的数字现在是双精度,而不是字符串/字符了。但是,当我尝试将它们用作字符串时,出现错误: my_cell2 = my_cell1; my_cell2(2:3, 2:3) = num2str(str2double(my_cell2(2:3, 2:3)) * 2); %Error: Conversion to cell from char is not possible. 如何将my_cell2相乘,使其最终等于my_cell3 ? [url=https://stackoverflow.com/q/59157890]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 05:07。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.