How to get the multiplication of elements in a row vector by using for loop
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
採用された回答
  KSSV
      
      
 2022 年 3 月 15 日
        % create a vector
A = [-2,4,9,-5,1];
Mult = 1;   % <----- this should be 1 
% create a for loop
for i = 1:length(A)
    Mult = Mult * A(i) ;
end
% display the result
disp(Mult);
prod(A)  % inbuit function 
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

