Trying to take a generated set of values in a matrix and add to it.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Anas Deiranieh's
il 30 Gen 2018
Commentato: Star Strider
il 30 Gen 2018
I'm trying to take the values I generate and use them for the next iteration of calculations and add a new column with the results for each iteration. The idea is Resistance. Note since the resistances are the same, the parallel resistance might look weird.
Another problem is that I only get zeros. How can I get those small values to show?
clear all
% CONSTANTS
mu = 18.27E-6; % Viscosity
x = 8*mu/pi; % Constants
D = 0.0018; % Branch Diameter in meters
NumPerGen = 1; % Starting at Generation 1
R = D/2; % Branch Radius in m
L = 3*D; % Branch Length in m 3:1 Length/Diameter ratio
for i = 1:24
Res = x*L/R^4;
ParaRes = Res/NumPerGen;
if i == 1
A(:,i) = [i,Res,ParaRes,NumPerGen,D,L];
else
A(:,i) = [i,Res + A(2,i-1),ParaRes,NumPerGen,D,L];
end
D = 0.79*D; % 21% Reduction in diameter
NumPerGen = 2*NumPerGen; % Doubles with each generation
end
0 Commenti
Risposta accettata
Star Strider
il 30 Gen 2018
Your code runs without error, and while some values of ‘A’ are small, none appear to be zero. (Use format short E rather than format short to see the element values. See the documentation on the format (link) function for details.)
What is it doing that you don’t want it to do, or what is it not doing that you do want it to do?
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!