MATLAB: Problem with quiver plot function

guiquiver

I am working on some code which I have been trying to tidy up into functions as I have several versions of it and it's quite repetitive. One of the tasks is a quiver plot, which I have written this function (Qplot) for:
function Qplot( space, lat, lon, u, v, size, thick )
%UNTITLED6 Summary of this function goes here
% Detailed explanation goes here
hold on
r = 1:str2double(space):length(lat);
r1 = lat(r);
s = 1:str2double(space):length(lon);
s1 = lon(s);
us = u(r, s);
vs = v(r, s);
q = quiver(s1,r1,us,vs);
q.AutoScaleFactor = str2double(size);
q.LineWidth = str2double(thick);
q.Color = 'k';
hold off
end
This works fine on most versions of the code except one. I have had to take out the Qplot bit out (it's there commented out) and replace it with the content of the function in full, like this:
function pushbutton23_Callback(hObject, eventdata, handles) %#ok<*INUSL>
h = guidata(gcbo);
axes(handles.axes2)
% Qplot(handles.edit22.String, h.latf, h.lonf, h.uf. h.vf, handles.edit21.String, handles.edit23.String)
hold on
r = 1:str2double(handles.edit22.String):length(h.latf);
r1 = h.latf(r);
s = 1:str2double(handles.edit22.String):length(h.lonf);
s1 = h.lonf(s);
us = h.uf(r, s);
vs = h.vf(r, s);
q = quiver(s1,r1,us,vs);
q.AutoScaleFactor = str2double(handles.edit21.String);
q.LineWidth = str2double(handles.edit23.String);
q.Color = 'k';
hold off
If I use the Qplot function in that one version only, I get this error message, but in no others where I'm doing exactly the same thing:
Struct contents reference from a non-struct array object.
Error in guiglobal>pushbutton23_Callback (line 280)
Qplot(handles.edit22.String, h.latf, h.lonf, h.uf. h.vf, handles.edit21.String, handles.edit23.String)
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in guiglobal (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)guiglobal('pushbutton23_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Any ideas?

Best Answer

You got a typo:
Qplot(handles.edit22.String, h.latf, h.lonf, h.uf. h.vf, handles.edit21.String, handles.edit23.String)
^^ this should be a ,