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

Übergabe eines Wertes aus einem edit-Feld an einen Graphen

 

lita06

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 08.01.2019, 14:07     Titel: Übergabe eines Wertes aus einem edit-Feld an einen Graphen
  Antworten mit Zitat      
Hallo,
Ich bin noch ein Octave Anfänger und versuche gerade eine grafische Benutzeroberfläche zu programmieren, mit der einfache Graphen geplotet werden können. Es soll möglich sein die x-Achse des Graphen innerhalb der GUI zu verändern, außerdem sollen die Variablen einer Sinus und Kosinus-Kurve eingegeben werden können und daraus der Graph dann geplotet werden.
Genauer gesagt möchte ich, dass, wenn ich eine Zahl in das Edit-Feld "xmin", "xmax" und "xstep" eingebe, soll sich die x-Achse danach anpassen. Im Code sollte das also folgendermaßen aussehen: x = xmin: xstep: xmax. Ich weiß aber nicht, wie ich die im Edit-Feld eingegebenen Werte an den Graphen übergebe.

Mein Code sieht folgendermaßen aus:

Code:
clear all
close all

fig1 = figure();

global ax
ax = axes('position', [0.05 0.5 0.4 0.4]);

e = 5
f = 0.05
x = -e:f:e;
A = 2;
b = 1;
c = 0;
d = 0;
y = A*sin(b*(x+c)+d);
plot (x,y);
axis ('tight');

hold on

G = 1;
h = 1;
i = 0;
j = 0;
y = G*cos(h*(x+i)+j);
plot (x,y);
axis ('tight');

function show_grid
  v = get (gcbo, 'value');
   grid (merge (v, 'on', 'off'));
end;

function minor_grid
  v = get (gcbo, 'value');
    grid ('minor', merge(v,'on','off'));
end;

function edit_plot_title
  global ax
  v = get (gcbo, 'string');
  set (get (ax, 'title'), 'string', v);
end;

function print_plot
     [filename, pathname] =  uiputfile ('*.pdf') ;
     if isequal(filename,0) || isequal(pathname,0)
      errordlg('No Print!','File Error: No valid path/filename');
     else
       print ([filename]);
    end ;
end;
 
plot_title_label = uicontrol (fig1,'style', 'text',...
                                'units', 'normalized',...
                                'string', 'Plot title',...
                                'horizontalalignment', 'left',...
                                'position', [0.6 0.9 0.35 0.08]);

plot_title_edit = uicontrol (fig1,'style', 'edit',...
                                'units', 'normalized',...
                                'string', 'edit me',...
                                'horizontalalignment','left', ...
                                'callback', @edit_plot_title,...
                                'position', [0.6 0.85 0.35 0.06]);                              
                               
grid_checkbox = uicontrol (fig1,'style', 'togglebutton',...
                             'units', 'normalized',...
                             'string', 'grid on',...
                             'callback', @show_grid,...
                             'position', [0.05 0.3 0.1 0.08]);
                             
minor_grid_toggle = uicontrol (fig1,'style', 'togglebutton',...
                                 'units', 'normalized',...
                                 'string', 'minor',...
                                 'callback', @minor_grid,...
                                 'position', [0.15 0.3 0.1 0.08]);

plot_button = uicontrol (fig1,'style', 'pushbutton',...
                           'units', 'normalized',...
                           'string', 'plot',...
                           'position', [0.05 0.1 0.35 0.08]);

bg = uibuttongroup (fig1, "Position", [ 0.5 0.1 0.2 0.3]);
                           
b1 = uicontrol (bg, "style", "checkbox",...
                "string", "Sinus",...
                "Position", [ 20 80 70 20 ]);
b2 = uicontrol (bg, "style", "checkbox",...
                "string", "Cosinus",...
                "Position", [ 20 50 70 20]);
b3 = uicontrol (bg, "style", "checkbox",...
                "string", "Tangens",...
                "Position", [ 20 20 70 20 ]);
               
amplitude = uicontrol (fig1, 'style', 'text',...
                         'units', 'normalized',...
                         'horizontalalignment', 'left',...
                         'string', 'amplitude',...
                         'position', [0.72 0.35 0.3 0.06]);
                         
sin_amplitude = uicontrol (fig1, 'style', 'edit',...
                              'units', 'normalized',...
                              'horizontalalignment', 'left',...
                              'string', 'x0 sin',...
                              'position', [0.72 0.3 0.08 0.04]);

cos_amplitude = uicontrol (fig1, 'style', 'edit',...
                              'units', 'normalized',...
                              'horizontalalignment', 'left',...
                              'string', 'x0 cos',...
                              'position', [0.72 0.23 0.08 0.04]);
                             
tan_amplitude = uicontrol (fig1, 'style', 'edit',...
                              'units', 'normalized',...
                              'horizontalalignment', 'left',...
                              'string', 'x0 tan',...
                              'position', [0.72 0.15 0.08 0.04]);
                             
periodenlaenge = uicontrol (fig1, 'style', 'text',...
                              'units', 'normalized',...
                              'horizontalalignment', 'left',...
                              'string', 'periode',...
                              'position', [0.85 0.35 0.3 0.06]);
                         
sin_periodenlaenge = uicontrol (fig1, 'style', 'edit',...
                                 'units', 'normalized',...
                                 'horizontalalignment', 'left',...
                                 'string', 'T sin',...
                                 'position', [0.85 0.3 0.08 0.04]);

cos_periodenlaenge = uicontrol (fig1, 'style', 'edit',...
                                  'units', 'normalized',...
                                  'horizontalalignment', 'left',...
                                  'string', 'T cos',...
                                  'position', [0.85 0.23 0.08 0.04]);
                             
tan_periodenlaenge = uicontrol (fig1, 'style', 'edit',...
                              'units', 'normalized',...
                              'horizontalalignment', 'left',...
                              'string', 'T tan',...
                              'position', [0.85 0.15 0.08 0.04]);
                             
xachsenabschnitt = uicontrol (fig1, 'style', 'text',...
                                'units', 'normalized',...
                                'horizontalalignment', 'left',...
                                'string', 'x-intercept',...
                                'position', [0.55 0.6 0.3 0.06]);
                               
xmin = uicontrol (fig1, 'style', 'edit',...
                    'units', 'normalized',...
                    'string', '2',...
                    'horizontalalignment', 'left',...
                    'position', [0.52 0.55 0.08 0.04]);
                   
xmax = uicontrol (fig1, 'style', 'edit',...
                    'units', 'normalized',...
                    'string', 'x max',...
                    'horizontalalignment', 'left',...
                    'position', [0.62 0.55 0.08 0.04]);
                   
xstep = uicontrol (fig1, 'style', 'edit',...
                    'units', 'normalized',...
                    'string', 'xstep',...
                    'horizontalalignment', 'left',...
                    'position', [0.72 0.55 0.08 0.04]);                    

print_pushbutton = uicontrol (fig1,'style', 'pushbutton',
                                'units', 'normalized',
                                'string', 'print plot',
                                'callback', @print_plot,
                                'position', [0.6 0.7 0.2 0.05]);
               


Vorab danke für eure Hilfe.

[EDITED, Jan, Bitte Code-Umgebung verwenden - Danke!]


Jan S
Moderator

Moderator


Beiträge: 11.057
Anmeldedatum: 08.07.10
Wohnort: Heidelberg
Version: 2009a, 2016b
     Beitrag Verfasst am: 08.01.2019, 15:14     Titel: Re: Übergabe eines Wertes aus einem edit-Feld an einen Grap
  Antworten mit Zitat      
Hallo lita06,

Was ist genau deine Frage?
Zitat:
Ich weiß aber nicht, wie ich die im Edit-Feld eingegebenen Werte an den Graphen übergebe.

Auf welche Codezeilen bezieht sich das genau?

Gruß, Jan
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.