From: Christopher on
Hi,

I am trying to use a lot of variables for my function but the optimization toolbox states that variable out of bounds because numel(x) = 2 and I can only use two variables say x(1) and x(2). . how can I increase the number of variables say using x(3),x(4),x(5),x(6)... etc.. .

Can Anyone help me. . pls

Thank you
From: James Tursa on
"Christopher " <christopher.serojano(a)veco.com.ph> wrote in message <i3thee$btv$1(a)fred.mathworks.com>...
> Hi,
>
> I am trying to use a lot of variables for my function but the optimization toolbox states that variable out of bounds because numel(x) = 2 and I can only use two variables say x(1) and x(2). . how can I increase the number of variables say using x(3),x(4),x(5),x(6)... etc.. .
>
> Can Anyone help me. . pls

MATLAB can hold roughly 65000 variables, so I doubt you are running into that limit. We can't possibly help you unless you provide more details, and ideally some code for us to look at.

James Tursa
From: James Tursa on
"Christopher " <christopher.serojano(a)veco.com.ph> wrote in message <i3thvb$6ia$1(a)fred.mathworks.com>...
> Hi,
>
> I am using a lot of variables for my function.. but I can't run the optimization toolbox. . an error occurs because of the number of variables I used and a numel(x)=2 and out of bounds will appear. . If I only use two variables say x(1) and x(2). . The optimtool runs.. I wish to use many variables say x(3), x(4), x(5). .etc. .
>
> Can anyone help me pls..
>
> thank you

Please do not double post.

James Tursa
From: Christopher on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i3tiah$bh2$1(a)fred.mathworks.com>...
> "Christopher " <christopher.serojano(a)veco.com.ph> wrote in message <i3thee$btv$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I am trying to use a lot of variables for my function but the optimization toolbox states that variable out of bounds because numel(x) = 2 and I can only use two variables say x(1) and x(2). . how can I increase the number of variables say using x(3),x(4),x(5),x(6)... etc.. .
> >
> > Can Anyone help me. . pls
>
> MATLAB can hold roughly 65000 variables, so I doubt you are running into that limit. We can't possibly help you unless you provide more details, and ideally some code for us to look at.
>
> James Tursa

thank you for your reply this is my code. .

function f = objfun(x)
a = xlsread('Optimization','weekday','c8:h103'); %demand CEDC - NPC
b = xlsread('Optimization','weekday','l8:m31'); % NPC rates
c = xlsread('Optimization','weekday','q7:q12'); % other rates
d = xlsread('Optimization','weekday','q13:q14');% Cemex and CPPC capacity fee
e = a(:,2).*0.25.*c(4,1); %Cost for CEDC per 15 min
i = 0.25.*c(5,1); %Cost for TPC per 15 min
g = 0.25.*c(1,1); % Cost for CPPC per 15 min
%Cost of NPC for every one hour
h = [sum(a(1:4,5)).*b(1,1).*0.25 sum(a(5:8,5)).*b(2,1).*0.25 sum(a(9:12,5)).*b(3,1).*0.25 sum(a(13:16,5)).*b(4,1).*0.25 sum(a(17:20,5)).*b(5,1).*0.25 sum(a(21:24,5)).*b(6,1).*0.25...
sum(a(25:28,5)).*b(7,1).*0.25 sum(a(29:32,5)).*b(8,1).*0.25 sum(a(33:36,5)).*b(9,1).*0.25 sum(a(37:40,5)).*b(10,1).*0.25 sum(a(41:44,5)).*b(11,1).*0.25 sum(a(45:48,5)).*b(12,1).*0.25...
sum(a(49:52,5)).*b(13,1).*0.25 sum(a(53:56,5)).*b(14,1).*0.25 sum(a(57:60,5)).*b(15,1).*0.25 sum(a(61:64,5)).*b(16,1).*0.25 sum(a(65:68,5)).*b(17,1).*0.25 sum(a(69:72,5)).*b(18,1).*0.25...
sum(a(73:76,5)).*b(19,1).*0.25 sum(a(77:80,5)).*b(20,1).*0.25 sum(a(81:84,5)).*b(21,1).*0.25 sum(a(85:88,5)).*b(22,1).*0.25 sum(a(89:92,5)).*b(23,1).*0.25 sum(a(93:96,5)).*b(24,1).*0.25]';

f = sum(e) + x(1)*c(5,1)*0.25 + x(2)*c(5,1)*0.25 +x(3)*c(5,1)*0.25+x(4)*c(5,1)*0.25+x(5)*c(5,1)*0.25+x(6)*c(5,1)*0.25+x(7)*c(5,1)*0.25+x(8)*c(5,1)*0.25+x(9)*c(5,1)*0.25+x(10)*c(5,1)*0.25+x(11)*c(5,1)*0.25+x(12)*c(5,1)*0.25+x(13)*c(5,1)*0.25+x(14)*c(5,1)*0.25+x(15)*c(5,1)*0.25+x(16)*c(5,1)*0.25+...
x(17)*c(5,1)*0.25

its not yet finished. . but i tried it in the optimtool. . then an error occurs. . index out of bounds then numel(x) = 2
From: Christopher on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i3tid6$e5o$1(a)fred.mathworks.com>...
> "Christopher " <christopher.serojano(a)veco.com.ph> wrote in message <i3thvb$6ia$1(a)fred.mathworks.com>...
> > Hi,
> >
> > I am using a lot of variables for my function.. but I can't run the optimization toolbox. . an error occurs because of the number of variables I used and a numel(x)=2 and out of bounds will appear. . If I only use two variables say x(1) and x(2). . The optimtool runs.. I wish to use many variables say x(3), x(4), x(5). .etc. .
> >
> > Can anyone help me pls..
> >
> > thank you
>
> Please do not double post.
>
> James Tursa


Im sorry I was unaware I posted twice. . I thought I was not able to post the first one. .
 |  Next  |  Last
Pages: 1 2 3
Prev: MATLAB IFFT
Next: subplots with different color maps