Multiply the vector organs
2 ビュー (過去 30 日間)
古いコメントを表示
How to multiply the vector parts without using a prod function
For example: s=[1 2 3 4], v=24
0 件のコメント
回答 (2 件)
John D'Errico
2017 年 12 月 27 日
編集済み: John D'Errico
2017 年 12 月 27 日
You want to multiply s*v, so perform that multiplication, but without using the * operator? May I ask why you want to do such a silly thing, instead of just doing s*v?
As long as one of them is a scalar, then conv will suffice.
conv(s,v)
It will be slower, less efficient. It will serve absolutely no purpose.
(See the comments in case I was wrong in interpreting the ambiguous question.)
Matt J
2017 年 12 月 27 日
編集済み: Matt J
2017 年 12 月 27 日
for i=1:4
v=exp(sum(log(s)));
end
1 件のコメント
John D'Errico
2017 年 12 月 27 日
You may be right here. the request may be to write v=prod(s), without use of prod, instead of forming the product s*v.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!