hab noch zwei fragen:
1) kann ich zwei graphen einzeichnen. also zB einmal die rechtewelle und dann nochmal die linke welle in einer anderen farbe? so als reflektierende welle.
2) kann ich parameter beim pllotten ändern? hab mir gedacht ich setzt t ganz hoch und wenn ich dann zB den Wert von w ändern möchte, mach ich das wärend die welle läuft und er übernimmts dann gleich.
UZone
Gast
Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
Verfasst am: 30.04.2010, 22:12
Titel:
achja eins noch
gibts irgendwo n knopf oder ne tastenkombination um das skript sofort zu beenden. hab nich immer lust abzuwarten bis die for schleife zu ende ist.
Für die anderen Möglichkeiten müsstest du dir eine GUI erstellen - schau dir doch in der Hilfe mal den entsprechenden Teil dazu ("Creating Graphical User Interfaces") an.
Grüße,
Harald
UZone
Gast
Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
Verfasst am: 01.05.2010, 20:03
Titel:
für die achsen hab ich was gefunden
das mit derm GUI werd ich gleich mal ausprobieren
Code:
x = -400:400;
t = 0:10000;
lambda = 100;
T = 10;
w = 2*pi/T;
k = 2*pi/lambda;
c = lambda/T;
phi0 = 180;
for l = 1:length(t) % E(1:400) = sin(w*t(l) + k*x(1:400) + phi0); % E(401:801) = sin(w*t(l) - k*x(401:801) + phi0); % E = sin(w*t(l) - sign((1:801)-400.5).*k.*x + phi0); %Welle von Mitte
E1(1:801) = sin(w*t(l) - k*x(1:801) + phi0); %Welle nach rechts
E2(1:801) = sin(w*t(l) + k*x(1:801) + phi0); %Welle nach links
E3 = E1+ E2;
% grid on xlim([-300300])% Bereich für x Achse set(gca, 'xtick', min(xlim):50:max(xlim)); % Bestimme die Einteilung der x Achse ylim([-2.52.5])% Bereich für y Achse set(gca, 'ytick', min(xlim):0.5:max(xlim)); % Bestimme die Einteilung der y Achse % xlabel('this goes across') % ylabel('this goes up')
sooo.. hab das jetzt mit dem gui gemacht und meine start, pause, exit buttons funktionieren.
jetzt hab ich ein slider eingefügt von 0 bis 100 und egal was ich mache entweder bekomm ich n debugging fehler oder es tut sich nix. das ist der code, der bis jetzt funktioniert, ohne die funktion des sliders
Code:
functionvarargout = EMW_d(varargin) % EMW_D M-file for EMW_d.fig % EMW_D, by itself, creates a new EMW_D or raises the existing % singleton*.
%
% H = EMW_D returns the handle to a new EMW_D or the handle to % the existing singleton*.
%
% EMW_D('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in EMW_D.M with the given input arguments.
%
% EMW_D('Property','Value',...) creates a new EMW_D or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before EMW_d_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to EMW_d_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 EMW_d
% Last Modified by GUIDE v2.5 01-May-2010 21:20:53
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @EMW_d_OpeningFcn, ...
'gui_OutputFcn', @EMW_d_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
ifnargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
% --- Executes just before EMW_d is made visible. function EMW_d_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 EMW_d (see VARARGIN)
% Choose default command line output for EMW_d
handles.output = hObject;
% UIWAIT makes EMW_d wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. functionvarargout = EMW_d_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)
x = -400:400;
t = 0:10000;
lambda =100;
T = 50;
w = 2*pi/T;
k = 2*pi/lambda;
c = lambda/T;
phi0 = 180;
for l = 1:length(t) % E(1:400) = sin(w*t(l) + k*x(1:400) + phi0); % E(401:801) = sin(w*t(l) - k*x(401:801) + phi0); % E = sin(w*t(l) - sign((1:801)-400.5).*k.*x + phi0); %Welle von Mitte
E1(1:801) = sin(w*t(l) - k*x(1:801) + phi0); %Welle nach rechts
E2(1:801) = sin(w*t(l) + k*x(1:801) + phi0); %Welle nach links
E3 = E1+ E2;
% grid on xlim([-400400])% Bereich für x Achse set(gca, 'xtick', min(xlim):100:max(xlim)); % Bestimme die Einteilung der x Achse ylim([-2.42.4])% Bereich für y Achse set(gca, 'ytick', min(xlim):0.5:max(xlim)); % Bestimme die Einteilung der y Achse % xlabel('this goes across') % ylabel('this goes up')
% --- 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) pause;
% --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) exit;
% --- 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
% --- 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. ifisequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);
end
P.S.: Wenn ein Fehler kommt, bitte sagen, WELCHER Fehler...
UZone
Gast
Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
Verfasst am: 01.05.2010, 23:34
Titel:
ja, sowas hatte ich mit google auch gefunden, aber das hat nich geklappt. ich bekomm das T (oder im screenshot lambda,habs mal mit beidem versucht) unterstrichen mit dem fehler "The value assigned to variable lambda might be unused"
ich kann die simulation trotzdem starten, aber das verändern des schieberegler bringt keine auswirkung
hab als min 0 als max 10000 und als value 100.
macht sich aber wie gesagt kein unterschied bemerkbar.
zur not kann ich auch textfeld oder so nehmen, wenn das vom programmieren her einfacher ist.
du verwendest ja in deinen Gleichungen auch nicht T oder lambda direkt, sondern nur w und k. D.h. du musst nach dem Auslesen von T bzw. lambda auch w bzw. k neu berechnen.
Grüße,
Harald
UZone
Gast
Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
Verfasst am: 02.05.2010, 19:00
Titel:
oh man, was ein amateurfehler
vielen dank, es klappt wie gewünscht ^^
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.