Decreasing varible into a loop
Ältere Kommentare anzeigen
Hello
I'm new programming and I have to sove this.
I Have to decrease one varible using i=0 and increasing by 1, i=i+1, but at same time I have another expression that depends of "i" and i need to drecreasing that varible, let you show:
i = 0;
x = b;
Fx = Fb;
Ek = abs(xe-x);
EA = Ek/Ek+1; %Here I've to solbe it
while 1
DeltaX = -Fx/(Fb-Fa)*(b-a);
x = x+DeltaX;
Fx = f(x);
Ek = abs(xe-x);; %Here I've to solbe it
disp ([i a b x Fx DeltaX Ek ]);
if(abs(DeltaX)<Tolerancia && abs(Fx)<Tolerancia)||i >=n
break;
end
a = b;
Fa = Fb;
b = x;
Fb = Fx;
i = i+1;
end
the equation is:
EA = Ek / E_k-1 it must be E_0/E_1 i =0 at the same time k = 2
Thanks
4 Kommentare
Jan
am 20 Jul. 2021
All we see is some code, which does not run. Several variables are not defined. You did neither mention in the question nor in the comments of the code, what you want to achieve. There readers might be able to guess, what you want, but this is not an efficient way to solve a problem.
- Start with inserting some comments, which explain clearly, what you want to achieve.
- Then define all missing variables
Steven Lord
am 20 Jul. 2021
Can you define variables with numbered names like E_1, E_2, E_3, ... which is what I think you're trying to do? Yes.
Miguel Angel Villegas Hernandez
am 20 Jul. 2021
Steven Lord
am 20 Jul. 2021
There's no element 0 in an array in MATLAB, so E(0) will error if E is a regular numeric array.
Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!