multiple a vector by a scalar using dot error
3 次查看(过去 30 天)
显示 更早的评论
So yet another problem for my day
I am trying to multiply a simple cell array fill of ints by a scalar value
if i print out
my_array{1:end , 1}
I get a bunch of ints back
However if i say
my_array{1:end , 1} * 5
I get a "too many input arguments" error from matlab
One would assume you need element wise multiplication here
So i resort to
my_array{1:end , 1} .* 5
And guess what, same error
too many input arguments
How is that even possible?
Suggestions?
0 个评论
回答(1 个)
DGM
2021-7-29
I guess I already mentioned this, but
A = num2cell(reshape(1:70,10,[]))
A{2:2:end,7} % this expression has multiple outputs (multiple scalars)
vertcat(A{2:2:end,7}) % this expression has only one output (a vector)
vertcat(A{2:2:end,7}) * 2 % this works
A{2:2:end,7} * 2 % this doesn't
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!