Solve non-linear equation with varying value
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    P K
 am 3 Jan. 2019
  
    
    
    
    
    Kommentiert: madhan ravi
      
      
 am 3 Jan. 2019
            I have a equation to solve
exp(-10*z)-9*exp(-2*z)+(8-4*x)=0
here 
x=linspace(0,1,101)
Since the equation itself would change to a new equation for each x, i am unable to figure out how to solve it. I need to solve for z. Can somebody suggest an approach to this.
0 Kommentare
Akzeptierte Antwort
  madhan ravi
      
      
 am 3 Jan. 2019
        
      Bearbeitet: madhan ravi
      
      
 am 3 Jan. 2019
  
      x=linspace(0,1,101);
Result=cell(1,numel(x)); % preallocate
for i = 1:numel(x)
Result{i}=fzero(@(z) exp(-10*z)-9*exp(-2*z)+(8-4*x(i)),[0 5]);
                                                    %   ^^^--initial guess interval
end
celldisp(Result)
[Result{:}] % double array
Gives:
>> [Result{:}]
ans =
  Columns 1 through 7
         0    0.0049    0.0096    0.0142    0.0187    0.0231    0.0274
  Columns 8 through 14
    0.0316    0.0357    0.0398    0.0438    0.0477    0.0517    0.0555
  Columns 15 through 21
    0.0594    0.0632    0.0670    0.0707    0.0744    0.0782    0.0818
  Columns 22 through 28
    0.0855    0.0892    0.0928    0.0964    0.1001    0.1037    0.1073
  Columns 29 through 35
    0.1109    0.1145    0.1181    0.1217    0.1252    0.1288    0.1324
  Columns 36 through 42
    0.1360    0.1396    0.1432    0.1468    0.1504    0.1540    0.1576
  Columns 43 through 49
    0.1612    0.1648    0.1685    0.1721    0.1758    0.1794    0.1831
  Columns 50 through 56
    0.1868    0.1905    0.1942    0.1979    0.2016    0.2054    0.2091
  Columns 57 through 63
    0.2129    0.2167    0.2205    0.2244    0.2282    0.2321    0.2359
  Columns 64 through 70
    0.2398    0.2438    0.2477    0.2517    0.2556    0.2596    0.2637
  Columns 71 through 77
    0.2677    0.2718    0.2759    0.2800    0.2842    0.2883    0.2925
  Columns 78 through 84
    0.2968    0.3010    0.3053    0.3096    0.3140    0.3183    0.3227
  Columns 85 through 91
    0.3272    0.3317    0.3362    0.3407    0.3453    0.3499    0.3545
  Columns 92 through 98
    0.3592    0.3640    0.3687    0.3735    0.3784    0.3833    0.3882
  Columns 99 through 101
    0.3932    0.3982    0.4033
>> 
6 Kommentare
  madhan ravi
      
      
 am 3 Jan. 2019
				
      Bearbeitet: madhan ravi
      
      
 am 3 Jan. 2019
  
			@Ravi Singh, See edited answer , if you got the answer to your question make sure to accept the answer else let know of your requirements which part is not clear.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


