WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

komisches Verhalten der GUI

 

pohloliq
Forum-Anfänger

Forum-Anfänger


Beiträge: 36
Anmeldedatum: 22.08.18
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 06.10.2018, 14:42     Titel: komisches Verhalten der GUI
  Antworten mit Zitat      
Hallo, bei folgendem Szenarion verhält sich meine GUI sehr merkwürdig:

Wenn man einen Slider verstellt z.b. einen von bk dann verändert sich der plot wie gewünscht . Wenn ich danach einen anderen Slider von bk oder ak verstelle ist auch alles in ordnung. Wenn ich nun einen dieser beiden gerade verstellten slider auf den wert null stelle geht eine gerade durch null. Was ja eigentlich nicht sein kann denn einen der beiden ak oder bk wie auch immer hat ja immernoch einen wert größer null und es müsste eine periodische funktion zu sehen sein im plot.


Woran könnte das liegen?

Hier der Code:


Code:

function varargout = fourier_synthi(varargin)
% FOURIER_SYNTHI MATLAB code for fourier_synthi.fig
%      FOURIER_SYNTHI, by itself, creates a new FOURIER_SYNTHI or raises the existing
%      singleton*.
%
%      H = FOURIER_SYNTHI returns the handle to a new FOURIER_SYNTHI or the handle to
%      the existing singleton*.
%
%      FOURIER_SYNTHI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FOURIER_SYNTHI.M with the given input arguments.
%
%      FOURIER_SYNTHI('Property','Value',...) creates a new FOURIER_SYNTHI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before fourier_synthi_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to fourier_synthi_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 fourier_synthi

% Last Modified by GUIDE v2.5 06-Oct-2018 15:16:45

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @fourier_synthi_OpeningFcn, ...
                   'gui_OutputFcn',  @fourier_synthi_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before fourier_synthi is made visible.
function fourier_synthi_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 fourier_synthi (see VARARGIN)

% Choose default command line output for fourier_synthi
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes fourier_synthi wait for user response (see UIRESUME)
% uiwait(handles.figure1);
ak = [get(handles.slider1,'value');get(handles.slider2,'value');get(handles.slider3,'value');
    get(handles.slider4,'value');get(handles.slider5,'value');get(handles.slider6,'value')];
handles.ak = ak;

bk = [0;get(handles.slider8,'value');get(handles.slider9,'value');get(handles.slider10,'value');
    get(handles.slider11,'value');get(handles.slider12,'value')];
handles.bk = bk;

N = str2num(get(handles.edit1,'string'));

handles.N = N;
guidata(hObject, handles);

fouriersynthi = fouriersynthese(N,ak,bk);

plot(fouriersynthi);



% --- Outputs from this function are returned to the command line.
function varargout = fourier_synthi_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;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.slider1,'value',0);
handles.ak(1) = get(handles.slider1,'value');
set(handles.slider2,'value',0);
handles.ak(2) = get(handles.slider2,'value');
set(handles.slider3,'value',0);
handles.ak(3) = get(handles.slider3,'value');
set(handles.slider4,'value',0);
handles.ak(4) = get(handles.slider4,'value');
set(handles.slider5,'value',0);
handles.ak(5) = get(handles.slider5,'value');
set(handles.slider6,'value',0);
handles.ak(6) = get(handles.slider6,'value');
set(handles.slider8,'value',0);
handles.bk(2) = get(handles.slider8,'value');
set(handles.slider9,'value',0);
handles.bk(3) = get(handles.slider9,'value');
set(handles.slider10,'value',0);
handles.bk(4) = get(handles.slider10,'value');
set(handles.slider11,'value',0);
handles.bk(5) = get(handles.slider11,'value');
set(handles.slider12,'value',0);
handles.bk(6) = get(handles.slider12,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);


function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double

N = str2double(get(handles.edit1,'string'));
if N == round(N) && N > 10
    M = int16(N);
    set(handles.edit1,'string',num2str(M));
else
    set(handles.edit1,'string','1000');
end
handles.N = str2num(get(handles.edit1,'string'));
fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);



% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on slider movement.
function slider8_Callback(hObject, eventdata, handles)
% hObject    handle to slider8 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.bk(2) = get(handles.slider8,'value');
fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider9_Callback(hObject, eventdata, handles)
% hObject    handle to slider9 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.bk(3) = get(handles.slider9,'value');
fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);


% --- Executes during object creation, after setting all properties.
function slider9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider10_Callback(hObject, eventdata, handles)
% hObject    handle to slider10 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.bk(4) = get(handles.slider10,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);
% --- Executes during object creation, after setting all properties.
function slider10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider11_Callback(hObject, eventdata, handles)
% hObject    handle to slider11 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.bk(5) = get(handles.slider11,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider12_Callback(hObject, eventdata, handles)
% hObject    handle to slider12 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.bk(6) = get(handles.slider12,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.ak(1) = get(handles.slider1,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject    handle to slider2 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.ak(2) = get(handles.slider2,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject    handle to slider3 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.ak(3) = get(handles.slider3,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider4_Callback(hObject, eventdata, handles)
% hObject    handle to slider4 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.ak(4) = get(handles.slider4,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider5_Callback(hObject, eventdata, handles)
% hObject    handle to slider5 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.ak(5) = get(handles.slider5,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on slider movement.
function slider6_Callback(hObject, eventdata, handles)
% hObject    handle to slider6 (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,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider
handles.ak(6) = get(handles.slider6,'value');

fouriersynthi = fouriersynthese(handles.N,handles.ak,handles.bk);

plot(fouriersynthi);

% --- Executes during object creation, after setting all properties.
function slider6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end


% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axes1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes1

 
Private Nachricht senden Benutzer-Profile anzeigen


Harald
Forum-Meister

Forum-Meister


Beiträge: 24.495
Anmeldedatum: 26.03.09
Wohnort: Nähe München
Version: ab 2017b
     Beitrag Verfasst am: 06.10.2018, 14:53     Titel:
  Antworten mit Zitat      
Hallo,

wenn du die handles-Struktur aktualisierst, musst du danach diesen Befehl verwenden:
Code:
guidata(hObject, handles);


Empfehlung: erst mal versuchen, anhand zwei statt zwölf Slidern ein Verständnis für das ganze entwickeln. So ist das für andere recht unübersichtlich und schwer zu erahnen, um was es gerade genau geht.

Grüße,
Harald
_________________

1.) Ask MATLAB Documentation
2.) Search gomatlab.de, google.de or MATLAB Answers
3.) Ask Technical Support of MathWorks
4.) Go mad, your problem is unsolvable ;)
Private Nachricht senden Benutzer-Profile anzeigen
 
pohloliq
Themenstarter

Forum-Anfänger

Forum-Anfänger


Beiträge: 36
Anmeldedatum: 22.08.18
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 06.10.2018, 14:55     Titel: komisches Verhalten der GUI
  Antworten mit Zitat      
genau das habe ich in jeder slider fct eben eingefügt und es funktionierte.


Danke
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

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
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

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.