필터 지우기
필터 지우기

how to solve equation for a given matrix

조회 수: 2 (최근 30일)
engineer
engineer 2019년 5월 23일
댓글: Adam Danz 2019년 5월 23일
Hi everybody
I have got equation which is ;
Eq = 0.4075*exp(-((e-14.87)/11.39).^2) + 0.5621*exp(-((e-18.64)/27.74).^2);
e is a 100*1 double matrix.
I would like to use the value of each row as an input to my function and save the results as matrix again. I used solve command, I could get any results.
Any suggestion is highly appreciated.
Thanks!!
  댓글 수: 5
engineer
engineer 2019년 5월 23일
Yes I have it 'e' as 100*1 double matrix. I just need to implement each value into the function and obtain the results as another matrix.
madhan ravi
madhan ravi 2019년 5월 23일
e = .... 100 X 1 values
Eq = 0.4075*exp(-((e-14.87)/11.39).^2) + 0.5621*exp(-((e-18.64)/27.74).^2); % doesn't this get you the required results?

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

채택된 답변

Adam Danz
Adam Danz 2019년 5월 23일
What's wrong with what you've already got?
%Vector method
e = rand(100,1)*10;
Eq = 0.4075*exp(-((e-14.87)/11.39).^2) + 0.5621*exp(-((e-18.64)/27.74).^2);
% Loop method
Eq2 = zeros(size(e));
for i = 1:numel(e)
Eq2(i) = 0.4075*exp(-((e(i)-14.87)/11.39).^2) + 0.5621*exp(-((e(i)-18.64)/27.74).^2);
end
% Are they equal?
isequal(Eq,Eq2) % = 1; yes
  댓글 수: 11
engineer
engineer 2019년 5월 23일
편집: engineer 2019년 5월 23일
Besides, how do you save the each x variable within loop in the code you provided?
Adam Danz
Adam Danz 2019년 5월 23일
sol(i) is the x values that satisfy the function. If you search for that warning within this forum you get lot's of feedback.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by