I am trying to program a value that runs from 10^-9 to 10^1. I have tried the following code and I have changed the e function to x10^() but my code will not run. It always gets stuck on this line. When I use e the error is invalid use of operator.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lorcan Conlon
le 8 Déc 2018
Modifié(e) : madhan ravi
le 8 Déc 2018
x0 = zeros(1,12);
% Values for w1
w_pool = 1:1:200;
% Preallocate result matrix
x_all = zeros(numel(w_pool),numel(x0))
% switch dispay off
options = optimoptions('fsolve','Display','off');
% Call fsolve in a loop
%g=1e10;
%d3=1.25e7;
%d1=0.5*d3;
for k = 1 : numel(w_pool);
%gs(k) = 10*((k-100)/100)*5e7;
%w3=gs(k);
h(k)=(((k-200)/200)+0.1)
b=h(k);
gs(k)=1eb;
I always get an error on the line where I try to calculate gs. I think this is a floating point error but I am not sure. Any help would be greatly appreciated!
0 commentaires
Réponse acceptée
madhan ravi
le 8 Déc 2018
Modifié(e) : madhan ravi
le 8 Déc 2018
I am not sure if your aware of this but 1e1 is equivalent to 10^(1) not x10(1) and your right number next to e should be an integer not a floating point.
I ran the following code without an error:
x0 = zeros(1,12);
% Values for w1
w_pool = 1:1:200;
% Preallocate result matrix
x_all = zeros(numel(w_pool),numel(x0))
% switch dispay off
% options = optimoptions('fsolve','Display','on');
% Call fsolve in a loop
%g=1e10;
%d3=1.25e7;
%d1=0.5*d3;
for k = 1 : numel(w_pool);
%gs(k) = 10*((k-100)/100)*5e7;
%w3=gs(k);
h(k)=(((k-200)/200)+0.1)
b=h(k);
gs(k)=10^(b);
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!