matlab
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
matlab [2014/04/30 14:31] – [Links] olli | matlab [2024/04/01 07:47] (aktuell) – [Zuweisen von Defaultwerten in Properties von Klassen] olli | ||
---|---|---|---|
Zeile 32: | Zeile 32: | ||
Um zu prüfen, ob eine Variablen von einem definierten Typ ist gibt es z.B. | Um zu prüfen, ob eine Variablen von einem definierten Typ ist gibt es z.B. | ||
<code matlab> | <code matlab> | ||
- | isa(x,' | + | isa(x,' |
ischar(x) | ischar(x) | ||
isfloat(x) | isfloat(x) | ||
Zeile 81: | Zeile 81: | ||
</ | </ | ||
+ | ===== Fehler beim Aufruf von Ghostscript aus MATLAB ===== | ||
+ | Viele Matlab-Skripte zum Erzeugen von hochqualitiven Plots für Veröffentlichungen, | ||
+ | < | ||
+ | Error: /undefined in /findfont | ||
+ | Operand stack: | ||
+ | 120 Helvetica ISOLatin1Encoding Helvetica Helvetica | ||
+ | Execution stack: | ||
+ | %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1916 1 3 %oparray_pop 1915 1 3 %oparray_pop --nostringval-- 1899 1 3 %oparray_pop 1787 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- 1868 5 5 %oparray_pop | ||
+ | Dictionary stack: | ||
+ | --dict: | ||
+ | Current allocation mode is local | ||
+ | Current file position is 10662 | ||
+ | GPL Ghostscript 9.07: Unrecoverable error, exit code 1 | ||
+ | </ | ||
+ | Das Problem ist, das MATLAB den LD_LIBRARY_PATH für seine Zwecke so verändert, das Ghostscript nicht mehr funktionsfähig ist. Vor dem Aufruf von Ghostscript muss LD_LIBRARY_PATH wieder geleert werden. Für export_fig muss in der Datei ghostscript.m die Zeile | ||
+ | <code matlab> | ||
+ | system(sprintf('" | ||
+ | </ | ||
+ | durch | ||
+ | <code matlab> | ||
+ | system(sprintf(' | ||
+ | </ | ||
+ | ersetzt werden. | ||
===== Ausgabe von fsolve ===== | ===== Ausgabe von fsolve ===== | ||
Nach der Ausführung von fsolve gibt die Funktion Informationen zur Lösung aus. Wenn das störend ist, kann die Ausgabe mit der Option " | Nach der Ausführung von fsolve gibt die Funktion Informationen zur Lösung aus. Wenn das störend ist, kann die Ausgabe mit der Option " | ||
Zeile 127: | Zeile 150: | ||
Die zugewiesenen DisplayNames lassen sich auch im Property Editor von Matlab anzeigen. | Die zugewiesenen DisplayNames lassen sich auch im Property Editor von Matlab anzeigen. | ||
+ | |||
+ | ===== Keine LaTeX-Interpretation (z.B. Tiefstellung) in Plotbeschriftung | ||
+ | Standardmäßig verwendet MATLAB einige [[LaTeX]]-ähnliche Befehle zur Textformatierung, | ||
+ | |||
+ | Für einzelne Titel: | ||
+ | <code matlab> | ||
+ | title(text, ' | ||
+ | </ | ||
+ | |||
+ | Für einzelne Legenden (Einträge als Cell Array): | ||
+ | <code matlab> | ||
+ | legend({' | ||
+ | </ | ||
+ | |||
+ | Für einzelne Legenden (mehrere Strings als Einträge): | ||
+ | <code matlab> | ||
+ | l = legend(' | ||
+ | set(l, ' | ||
+ | </ | ||
+ | |||
+ | Global: | ||
+ | <code matlab> | ||
+ | set(0, ' | ||
+ | </ | ||
===== Animationen erstellen ===== | ===== Animationen erstellen ===== | ||
Zeile 160: | Zeile 207: | ||
anzeigen lassen. | anzeigen lassen. | ||
+ | ===== Zuweisen von Defaultwerten in Properties von Klassen ===== | ||
+ | Defaultwerte für Properties von Klassen (=Membervariablen) lassen sich entweder in den Properties direkt setzen oder beim Aufruf des Konstruktors. | ||
+ | |||
+ | Beispiel mit Zuweisung direkt in den Properties: | ||
+ | <code matlab> | ||
+ | classdef MyClass | ||
+ | | ||
+ | PropertyOne = 42; | ||
+ | PropertyTwo = MyClass2(); | ||
+ | end | ||
+ | end | ||
+ | </ | ||
+ | Dabei wird die rechte Seite nur beim ersten Instanzieren der Klasse MyClass ausgewertet. Der Konstruktor von MyClass2 wird deshalb nur //einmal// ausgeführt. PropertyTwo enthält daher immer das gleiche Objekt, siehe | ||
+ | [[https:// | ||
+ | |||
+ | Beispiel mit Zuweisung beim Aufruf des Konstruktors: | ||
+ | <code matlab> | ||
+ | classdef MyClass | ||
+ | | ||
+ | PropertyOne | ||
+ | PropertyTwo; | ||
+ | end | ||
+ | | ||
+ | function obj = MyClass() | ||
+ | | ||
+ | | ||
+ | end | ||
+ | end | ||
+ | end | ||
+ | </ | ||
+ | Auf diese Art wird bei jeder Instanzierung von MyClass eine Auswertung der rechten Seiten vorgenommen. Der Konstruktor von MyClass2 wird daher // | ||
+ | [[https:// | ||
+ | |||
+ | ===== MATLAB-Skript von der Kommandozeile starten ===== | ||
+ | Um ein MATLAB-Skript ohne grafische Ausgabe zu starten, kann folgender Befehl verwendet werden: | ||
+ | <code bash> | ||
+ | matlab -nosplash -nodisplay -nodesktop -r scriptToStart | ||
+ | </ | ||
===== Links ===== | ===== Links ===== | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
- | * [[http://research.microsoft.com/en-us/um/ | + | * [[https://github.com/tminka/lightspeed|Lightspeed |
- | * [[http:// | + | |
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[https:// |
matlab.1398861109.txt.gz · Zuletzt geändert: 2014/04/30 14:31 von olli