フィルターのクリア

The greatest common divisor

1 回表示 (過去 30 日間)
Kentman
Kentman 2014 年 10 月 15 日
コメント済み: Kentman 2014 年 10 月 15 日
Hello,
I just created function for greatest common divisor of two numbers. I want now to do the same for a whole matrix, that means for more than two numbers. But I don't know the idea, i was just confused how to write the program.
The original function was NSD, so i tried to build another one named NSD1 and call the original NSD inside it:
  • _function [value]=NSD1(A)
while i<=size(A,2)
val=NSD(A(i),A(i-1));
end
end_ *
and this is of course wrong, i thought of some tricks which are quite stupid. Can you help me?

採用された回答

Sean de Wolski
Sean de Wolski 2014 年 10 月 15 日
Use a for loop over the elements in the matrix
for ii = 1:numel(A)
b(ii) = existing_gcd_algorithm(A(ii),c)
end
  1 件のコメント
Kentman
Kentman 2014 年 10 月 15 日
what do you mean by c?.. can you tell more of the pricniple of this method?

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by