From: AP on
I've started working with the GUI in Matlab, and at several places in my code, I use a a 'blank' column vector with the zeros function

e.g. Val = zeros(2*N+1,1)

and this goes on producing errors, either at this point or later.

How should I enter this in a GUI? It works fine as an ordinary function.

Thanks.
From: Sean on
"AP " <apb1508138(a)gmail.com> wrote in message <i39rpm$9gq$1(a)fred.mathworks.com>...
> I've started working with the GUI in Matlab, and at several places in my code, I use a a 'blank' column vector with the zeros function
>
> e.g. Val = zeros(2*N+1,1)
>
> and this goes on producing errors, either at this point or later.
>
> How should I enter this in a GUI? It works fine as an ordinary function.
>
> Thanks.

What are the errors?
From: Jan Simon on
Dear AP,

> I've started working with the GUI in Matlab, and at several places in my code, I use a a 'blank' column vector with the zeros function
>
> e.g. Val = zeros(2*N+1,1)
>
> and this goes on producing errors, either at this point or later.
> How should I enter this in a GUI? It works fine as an ordinary function.

How can the definition of a variable produce errors "later"?
How do you "enter" the definition of the variable in a GUI?
It is always a good idea to post the error message, because Matlab creates meaningful messages which explain how the problem can be solved.

Kind regards, Jan
From: AP on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <i39s4s$2f6$1(a)fred.mathworks.com>...
> "AP " <apb1508138(a)gmail.com> wrote in message <i39rpm$9gq$1(a)fred.mathworks.com>...
> > I've started working with the GUI in Matlab, and at several places in my code, I use a a 'blank' column vector with the zeros function
> >
> > e.g. Val = zeros(2*N+1,1)
> >
> > and this goes on producing errors, either at this point or later.
> >
> > How should I enter this in a GUI? It works fine as an ordinary function.
> >
> > Thanks.
>
> What are the errors?

Initially ---

"Warning: Size vector should be a row vector with integer elements. "

and

"??? Attempted to access OptVal(1.4); index must be a positive integer or logical."

(the latter part of my code is:


Vals = zeros(2*N+1,1)
Vals(1) = SO*d^N
for i = 2:2*N+1
Vals(i) = u*Vals(i-1)
end
OptVal = zeros (2*N+1,1)
for i = 1:2:2*N+1
OptVal(i) = max(SVals(i)-K,0)
end
for t=1:N
for i= (t+1):2: (2*N+1-t)
OptVal(i) = p_u*OptVal(i+1) + p_d*OptVal(i-1)
end
end
price = OptVal(N+1)
p = num2str(price)
set(handles.answer,'String',price);
guidata(hObject, handles);
From: Walter Roberson on
AP wrote:
> "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message
> <i39s4s$2f6$1(a)fred.mathworks.com>...
>> "AP " <apb1508138(a)gmail.com> wrote in message
>> <i39rpm$9gq$1(a)fred.mathworks.com>...
>> > I've started working with the GUI in Matlab, and at several places
>> in my code, I use a a 'blank' column vector with the zeros function >
>> > e.g. Val = zeros(2*N+1,1)
>> > > and this goes on producing errors, either at this point or later.
>> > > How should I enter this in a GUI? It works fine as an ordinary
>> function. > > Thanks.
>> What are the errors?
>
> Initially ---
>
> "Warning: Size vector should be a row vector with integer elements. "
>
> and
> "??? Attempted to access OptVal(1.4); index must be a positive integer
> or logical."

Are you sure that N is an integer?