mein problem, ist, dass ich in einer gui in axes1 erst eine zeitreihe laden und plotten will (was auch funktioniert) und danach in axes2 nachklicken des buttons fft die fft des gezeigten signals plotten möchte. irgenwie bekomme ich aber nicht hin, dass die variablen übernommen werden und es kommt zur fehlermeldung
Code:
functionvarargout = test_fft_aus_zeitsignal(varargin) % TEST_FFT_AUS_ZEITSIGNAL MATLAB code for test_fft_aus_zeitsignal.fig % TEST_FFT_AUS_ZEITSIGNAL, by itself, creates a new TEST_FFT_AUS_ZEITSIGNAL or raises the existing % singleton*.
%
% H = TEST_FFT_AUS_ZEITSIGNAL returns the handle to a new TEST_FFT_AUS_ZEITSIGNAL or the handle to % the existing singleton*.
%
% TEST_FFT_AUS_ZEITSIGNAL('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in TEST_FFT_AUS_ZEITSIGNAL.M with the given input arguments.
%
% TEST_FFT_AUS_ZEITSIGNAL('Property','Value',...) creates a new TEST_FFT_AUS_ZEITSIGNAL or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before test_fft_aus_zeitsignal_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to test_fft_aus_zeitsignal_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 test_fft_aus_zeitsignal
% Last Modified by GUIDE v2.5 30-Jul-2012 16:29:29
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @test_fft_aus_zeitsignal_OpeningFcn, ...
'gui_OutputFcn', @test_fft_aus_zeitsignal_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before test_fft_aus_zeitsignal is made visible. function test_fft_aus_zeitsignal_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 test_fft_aus_zeitsignal (see VARARGIN)
% Choose default command line output for test_fft_aus_zeitsignal
handles.output = hObject;
% UIWAIT makes test_fft_aus_zeitsignal wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = test_fft_aus_zeitsignal_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;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----- Zeitsignal laden und plotten---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- 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)
filename = uigetfile('*.xls','Auswahl der gewünschten Zeitreihe');
[nums, txt] =xlsread(filename);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----- FFT des Zeitsignals erzeugen und plotten---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
Ta = 6.65e-6; % Abtastrate
fa = 1/Ta; % Abtastfrequenz
fn = fa/2; % Nyquistfrequenz
L = length(x); % Länge des Zeitsignals
N = 2^nextpow2(L); % gewünschte FFT-Länge (N=2^x, sonst wird der DFT-Algorithmus verwendet!)
df = fa/N; % Frequenzauflösung
win = hann(L)';
y_win = h.y'.*win; % Fensterung ohne Amplitudenkorrektur
%y_win = y'.*win*N/sum(win); % Fensterung mit Amplitudenkorrektur
max_y = max(abs(y_win))*1.1;
Bitte poste eine neue Frage als neuen Thread, statt Dich an einen vorhandenen und als "beantwortet" gekennzeichneten Thread anzuhängen. Danke!
Zitat:
Code:
function pushbutton2_Callback(hObject, eventdata, handles)
Ta = 6.65e-6; % Abtastrate
fa = 1/Ta; % Abtastfrequenz
fn = fa/2; % Nyquistfrequenz
L = length(x); % Länge des Zeitsignals
Nun, die Fehlermeldung ist eindeutig und aussagekräftig. Es lohnt sich immer, Matlabs sehr gute Fehlermeldungen durchzulesen.
Ist es sinnvoll, dass ich den Inhalt nochmal wiederhole? Falls ja: Die Variable "x" ist in der Zeile "L = length(x)" nicht definiert. Ein Lösungsvorschlag ist nicht möglich, da ich ja nicht weiß, woher das "Zeitsignal" kommen soll.
Eventuell möchtest Du die Variable "x", die in einer anderen Unterfunktion vorkommt, im GUI speichern:
Code:
x =nums(:,1); % x-Vektor
y =nums(:,2); % y-vektor
handles.x = x;
guidata(hObject, handles);
Das Problem Variablen im handles-Struct zu speichern wurde schon so oft im Forum besprochen, dass Du einfach mal nach "guidata" suchen kannst.
Gruß, Jan
Pepsi
Gast
Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
Verfasst am: 26.09.2012, 13:16
Titel:
ok, das mit der speicherung als handles.x hab ich gebraucht...
DANKE!
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.