using a 'for' loop to create a vector
Afficher commentaires plus anciens
I need to put the roots of the equation shown (f) into a vector of one column. I have managed to go some way with this however i keep getting the following error:
_Attempted to access x(6,1); index must be a positive integer or logical.
Error in sec_C1 (line 24)
x((a+0.01)*100,1)= (fzero(f,[0,0.1])_
How can I get this to work, and is there a better way to obtain the vector?
w =0.001;
x = ones(1,61)
for a = 0:0.01:0.6
g = @(v) (2048*((1+v).^4) + 128*((1+v).^2).*a.^6 + a.^12 + 16*(1+v).*sqrt(16384*((1+v).^6) + 2048*((1+v).^4).*a.^6 + 80*((1+v).^2).*a.^12 + a.^18)).^(1/3);
r =@(v) (1/(16*(1+v))).*( a.^4 + (a.^8)./g(v) + g(v) );
alpha= @(v) (a./r(v));
A= @(v) 2*pi*(r(v).^2)*(1+sqrt(1-alpha(v).^2));
epsilon = @(v) 1/2*(A(v)/(4*pi-pi*a.^2)-1);
f= @(v) (1-sqrt(1-alpha(v).^2)).*epsilon(v) + (epsilon(v).^2) - w;
format long % shows more d.p
%find roots
x((a+0.01)*100,1)= (fzero(f,[0,0.1]))
end
Réponse acceptée
Plus de 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!