Please, I would appreciate any assistance on debugging the attached code.
Afficher commentaires plus anciens
The first section of the code is okay, but I am having it difficult solving for uu and ud in the attached code. I want to continue solving for the values of uu and ud as long the conditions in the while loops are valid. Pls, see the attached file.
This is the pseudo code:
for j=1:N
k=1;
uu(k,j)=0;
Lou(k,j)=2;
p(k,j)=6000;
pQ(k,j)=asin(1+Lou(k,j));
Lh2(j)=200;
k22(k,j)=Lh2(j)./Lou(k,j);
if p(k,j)>pQ(k,j)
while Lou(k,j)<Lh2
k22f(k,j)=Lh2(j)./(Lou(k,j)+uus);
funLu(k,j)=asin(1+k22f(k,j));
testfunLu=@(x)eval(subs(funLu(k,j),uus,x))-p(k,j);
uuf(k,j)=fsolve(testfunLu,55);
uu(k+1,j)=uuf(k,j);
Lou(k+1,j)=Lou(k,j)+uu(k+1,j);
k22(k+1,j)=Lh2(j)./(Lou(k+1,j)+uu(k+1,j));
p(k+1,j)=p(k,j);
k=k+1
end
end
end
9 commentaires
Chad Greene
le 1 Avr 2016
Nothing attached.
Isaac
le 1 Avr 2016
Isaac
le 1 Avr 2016
Modifié(e) : Walter Roberson
le 2 Avr 2016
Chad Greene
le 1 Avr 2016
Yikes. I can tell right away that you're unlikely to get a response because there's too much to sift through. Please trim your code down to a MWE and clearly describe what you mean when you say you're having difficulty.
Isaac
le 1 Avr 2016
Modifié(e) : per isakson
le 2 Avr 2016
jgg
le 1 Avr 2016
This isn't a minimal example. How is Lou(k,j) updated? What is the solving criterion? You're making this very difficult for anyone to help you with.
For instance, the code you've provided doesn't even run because uuf{k,j}(2) is a single value, not a vector. Additionally, you're not pre-declaring any of your variables, so they change size every iteration which makes it impossible to tell how anything should be structured.
Isaac
le 1 Avr 2016
Isaac
le 1 Avr 2016
Modifié(e) : per isakson
le 2 Avr 2016
Isaac
le 1 Avr 2016
Modifié(e) : per isakson
le 2 Avr 2016
Réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!