how to solve equation for a given matrix
    7 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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 件のコメント
  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
    
      
 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 件のコメント
  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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


