Azzera filtri
Azzera filtri

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.

11 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

madhan ravi
madhan ravi il 8 Dic 2018
Modificato: madhan ravi il 8 Dic 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

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by