hallo leute, gleich mit dem ersten beitrag bin ich lästig.
folgendes m-file für ein gui läuft nicht wie ich es möchte.
die fehlermeldung lautet:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> string1>refresh_Callback at 434
x(2) = va*dt + x(1);
Code:
functionvarargout = string1(varargin) % STRING1 M-file for string1.fig % STRING1, by itself, creates a new STRING1 or raises the existing % singleton*.
%
% H = STRING1 returns the handle to a new STRING1 or the handle to % the existing singleton*.
%
% STRING1('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in STRING1.M with the given input arguments.
%
% STRING1('Property','Value',...) creates a new STRING1 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before string1_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to string1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help string1
% Last Modified by GUIDE v2.5 08-Nov-2008 20:08:00
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @string1_OpeningFcn, ...
'gui_OutputFcn', @string1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before string1 is made visible. function string1_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to string1 (see VARARGIN)
% Choose default command line output for string1
handles.output = hObject;
% UIWAIT makes string1 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. functionvarargout = string1_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure varargout{1} = handles.output;
% handles.hintergrund = imread('X:\file_store\FH!!!!!!!\AINF_mset1\Bergpower 2.0e\4.jpg') % axes(handles.axes1); % image(handles.hintergrund); % axis off;
handles.hintergrund = imread('X:\file_store\FH!!!!!!!\AINF_mset1\Bergpower 2.0e\Bergpower 2.0\unten1.jpg') axes(handles.axes2);
image(handles.hintergrund);
axis off;
handles.hintergrund = imread('X:\file_store\FH!!!!!!!\AINF_mset1\Bergpower 2.0e\Bergpower 2.0\teifl1.jpg') axes(handles.axes4);
image(handles.hintergrund);
axis off;
%-------------------------------------------------------------------------
% --- Executes on button press in but_zoom. function but_zoom_Callback(hObject, eventdata, handles) % hObject handle to but_zoom (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
zoom on;
%-------------------------------------------------------------------------
% --- Executes on button press in pushbutton4. function but_overview_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
zoom out;
%-------------------------------------------------------------------------
% --- Executes on button press in but_pan. function but_pan_Callback(hObject, eventdata, handles) % hObject handle to but_pan (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
pan xon;
%-------------------------------------------------------------------------
%set(handles.popupmenu1,'Visible','on'); %Pop up Menu1 einblenden
% set(handles.popupmenu2,'Visible','on'); %Pop up Menu 2 einblenden
% popup_sel_index1 = get(handles.popupmenu1, 'Value'); %Auswahlen - Settings Pup up Menü1 % switch popup_sel_index1 % case 1 % t=x_p; % P=y4; % case 2 % x1=x_p; % Y=y5; % case 3 % x1=x_s; % Y=y1; % case 4 % x1=x_s; % Y=y2; % case 5
% end
% popup_sel_index2 = get(handles.popupmenu2, 'Value'); %%Auswahlen - Settings Pup up Menü2 % switch popup_sel_index2 % case 1 % plot(t,x); % case 2 % plot(t1,vf1); % end
%---------------------------------------------------------------Cursor
% --- Executes on button press in cursor_on. function cursor_on_Callback(hObject, eventdata, handles) % hObject handle to cursor_on (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
dualcursor on
dualcursor([010], [-.13 .3;-.13 .4])
%---------------------------------------------------button zum schließen
function close_Callback(hObject, eventdata, handles) % hObject handle to close (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in popupmenu2. function popupmenu2_Callback(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'string1') returns popupmenu2 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties. function popupmenu2_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. ifispc set(hObject,'BackgroundColor','white');
else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in popupmenu1. function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'string1') returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. ifispc set(hObject,'BackgroundColor','white');
else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function v0_Callback(hObject, eventdata, handles) % hObject handle to v0 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'string1') returns contents of v0 as text % str2double(get(hObject,'string1')) returns contents of v0 as a double
%global v0;
%checks to see ifinputis empty. if so, default input1_editText to zero
if(isempty(v0)) set(hObject,'String','0') end guidata(hObject, handles);
% v0 = str2double(get(hObject, 'String')); % if isnan(v0) % set(hObject, 'String', 0); % errordlg('Input must be a number','Error'); % end % % % speichern des neuen eintrages: % % handles.metricdata.v0 = v0; % guidata(hObject,handles);
% --- Executes during object creation, after setting all properties. function v0_CreateFcn(hObject, eventdata, handles) % hObject handle to v0 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function v2_Callback(hObject, eventdata, handles) % hObject handle to v2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'string1') returns contents of v2 as text % str2double(get(hObject,'string1')) returns contents of v2 as a double
%checks to see ifinputis empty. if so, default input1_editText to zero
if(isempty(v2)) set(hObject,'String','0') end guidata(hObject, handles);
% global v2; % % v2 = str2double(get(hObject, 'String')); % if isnan(v2) % set(hObject, 'String', 0); % errordlg('Input must be a number','Error'); % end % % % speichern des neuen eintrages: % % handles.metricdata.v2 = v2; % guidata(hObject,handles)
% --- Executes during object creation, after setting all properties. function v2_CreateFcn(hObject, eventdata, handles) % hObject handle to v2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function radius_Callback(hObject, eventdata, handles) % hObject handle to radius (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'string1') returns contents of radius as text % str2double(get(hObject,'string1')) returns contents of radius as a double
%checks to see ifinputis empty. if so, default input1_editText to zero
if(isempty(radius)) set(hObject,'String','0') end guidata(hObject, handles);
% global radius; % % radius = str2double(get(hObject, 'String')); % if isnan(radius) % set(hObject, 'String', 0); % errordlg('Input must be a number','Error'); % end
% --- Executes during object creation, after setting all properties. function radius_CreateFcn(hObject, eventdata, handles) % hObject handle to radius (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
function winkel_Callback(hObject, eventdata, handles) % hObject handle to winkel (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'string1') returns contents of winkel as text % str2double(get(hObject,'string1')) returns contents of winkel as a double
%checks to see ifinputis empty. if so, default input1_editText to zero
if(isempty(winkel)) set(hObject,'String','0') end guidata(hObject, handles);
% global winkel; % % winkel = str2double(get(hObject, 'String')); % if isnan(winkel) % set(hObject, 'String', 0); % errordlg('Input must be a number','Error'); % end
% --- Executes during object creation, after setting all properties. function winkel_CreateFcn(hObject, eventdata, handles) % hObject handle to winkel (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. ifispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');
end
%-------------------------------------------------------------------------
% --- Executes on button press in refresh. function refresh_Callback(hObject, eventdata, handles) % hObject handle to refresh (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
t = 0:dt:(n-1)*dt;
t1 = dt:dt:(n-1)*dt; %Intervall der Geschw. um eins kürzer da durch die Ableitung ein Wert wegfällt
vf1 = vf1*3.6; %umrechung von m/s auf km/h
Du musst den String erst wieder in eine Zahl umwandeln (z.B. mit "str2double"), ansonsten nimmt er glaub ich die ASCII-Werte eines jeden einzelnen Zeichens her (so ergibt '34'/1 -> 51 52). Den Rest habe ich mir noch nicht angesehen, aber die Fehlermeldung kommt daher, dass dir deine Gleichung "x(2) = ...." nicht ein Skalar, sondern ein Array zurückliefert - und du versuchst dies in ein Skalar zu schreiben - was natürlich nicht geht.
Achja, versuch bitte beim nächsten Mal nicht den ganzen Source-Code, sondern nur den relevanten Teil (Minimalbeispiel) zu posten.
MfG
Einstellungen und Berechtigungen
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.