필터 지우기
필터 지우기

Multiplication implementation help?

조회 수: 1 (최근 30일)
Steve
Steve 2011년 10월 6일
Hello Experts,
I need to write MATLAB code and to build a product like this:
for i from 1 to d, multiplication (x(i)-x(j)). x is a row vector of size d.
Here is what I did:
m = 0;
for i=1:d
for j=1:d
if i~=j
m = prod(x(i)-x(j));
end
end
end
But I am not sure if I am right...can you please help me with this?
  댓글 수: 2
Fangjun Jiang
Fangjun Jiang 2011년 10월 6일
format your code next time
Steve
Steve 2011년 10월 6일
But am I right?

댓글을 달려면 로그인하십시오.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 10월 6일
You need to initialize m=1 and then do m=m*(x(i)-x(j)), or m=prod([m,x(i)-x(j)]). Use a test vector of x to verify the result.
  댓글 수: 1
Steve
Steve 2011년 10월 6일
Thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Code Analysis에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by