loop for equation a*b-c*d*(p-1)=1

조회 수: 4 (최근 30일)
rjnt Kaur
rjnt Kaur 2013년 4월 12일
I need matlab loop code for equation a*b-c*d*(p-1)=1 where a nad c are randomly selected and b,d and p are calculated previously...loop must satisfy the equation and then display a and c

채택된 답변

Yao Li
Yao Li 2013년 4월 12일
b=1;
d=2;
p=3;
c=rand(10);
for i=1:length(c)
a(i)=1+c(i)*d*(p-1)/b;
fprintf('a=%d c=%d\n',a(i),c(i))
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 4월 12일
This does not randomly select "a"... but randomly selecting both "a" and "c" is unlikely to ever find a solution. See discussion in the original of this thread http://www.mathworks.co.uk/matlabcentral/answers/71707-need-help-on-equation-a-b-c-d-t-1-1
Walter Roberson
Walter Roberson 2013년 4월 12일
Algebraic correction:
a(i)=(1+c(i)*d*(p-1))/b;

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by