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 次查看(过去 30 天)
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!

采纳的回答

madhan ravi
madhan ravi 2018-12-8
编辑:madhan ravi 2018-12-8
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 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by