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

[MEX] Matlab Crash NACH erfolgreichem Durchlauf!?!

 

OpiumTom
Forum-Newbie

Forum-Newbie


Beiträge: 4
Anmeldedatum: 05.07.10
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 26.07.2010, 17:12     Titel: [MEX] Matlab Crash NACH erfolgreichem Durchlauf!?!
  Antworten mit Zitat      
Hi,
habe eine kleine MEX - Funktion geschrieben die später (!) einmal externe Messdaten zur Verbesserung von Prognose-Entscheidungen integrieren soll.

Aktuell kommen jedoch noch BEIDE Daten aus dem Aufruf und sollen in dieser MEX Funktion zunächst aus dem Objekt extrahiert, und dann weiterverarbeitet werden.

Code:

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
   mxArray *lsg_a, *lsg_b;
   int schnitt, i;
   int mrows,ncols;
   /*Die Loesungen sind Cell-Arrays*/
   lsg_a = mxGetProperty(prhs[0], 0, "Loesung");
   lsg_b = mxGetProperty(prhs[1], 0, "Loesung");
   mrows = mxGetM(lsg_a);
   ncols = mxGetN(lsg_a);
   plhs[0] = mxCreateCellMatrix(mrows, ncols);
   plhs[1] = mxCreateCellMatrix(mrows, ncols);

   schnitt = mrows / 2;

   for (i = 0; i <= schnitt; i++) {
      mxSetCell(plhs[0], i, mxGetCell(lsg_a, i));
      mxSetCell(plhs[0], i + mrows, mxGetCell(lsg_a, i + mrows));
      mxSetCell(plhs[1], i, mxGetCell(lsg_b, i));
      mxSetCell(plhs[1], i + mrows, mxGetCell(lsg_a, i + mrows));
      }
     
   for (i = schnitt + 1; i<=mrows; i++) {
      mxSetCell(plhs[0], i, mxGetCell(lsg_b, i));
      mxSetCell(plhs[0], i + mrows, mxGetCell(lsg_b, i + mrows));
      mxSetCell(plhs[1], i, mxGetCell(lsg_a, i));
      mxSetCell(plhs[1], i + mrows, mxGetCell(lsg_a, i + mrows));
      }
}
 


Die Funktion wird anstandslos von Matlab kompiliert. Sie liefert nach Aufruf auch das korrekte Ergebniss, jedoch verabschiedet Matlab sich anschließend mit einem

Code:

------------------------------------------------------------------------
       Segmentation violation detected at Mon Jul 26 16:58:12 2010
------------------------------------------------------------------------

Configuration:
  MATLAB Version:   7.9.0.529 (R2009b)
  MATLAB License:   355462
  Operating System: Microsoft Windows Vista
  Window System:    Version 6.1 (Build 7600)
  Processor ID:     x86 Family 6 Model 7 Stepping 10, GenuineIntel
  Virtual Machine:  Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
  Default Encoding:  windows-1252

Fault Count: 1

Register State:
  rax = 00000000000004fc   rbx = 0000000006e4b008
  rcx = 000000003129e4a0   rdx = 0000000001029518
  rbp = 0000000000000068   rsi = 000000003129e4a0
  rdi = 0000000000000001   rsp = 0000000001029420
   r8 = 0000000078afe770    r9 = 000000003694d560
  r10 = 0000000001029628   r11 = 000000003694d540
  r12 = 0000000000000001   r13 = 0000000001029518
  r14 = 0000000078a4bd98   r15 = 0000000000000000
  rip = 000000007898f764   flg = 0000000000010206

Stack Trace:
  [  0] 000000007898F764                 mcos.dll+1046372 (QueryMLFcnTable_mcos+006388)
  [  1] 000000007CEC3910                libmx.dll+014608 (mxGetNumberOfBytes+000496)
  [  2] 000000007CEC38B8                libmx.dll+014520 (mxGetNumberOfBytes+000408)
  [  3] 0000000078D32C2B        libmwbuiltins.dll+2042923 (init_registerSetDefaultSaveLevel+028395)

Please follow these steps to report this problem to The MathWorks so we
have the best chance of correcting it:

The next time MATLAB is launched under typical usage, a dialog box will
open to help you send the error log to The MathWorks. Alternatively, you
can send an e-mail to segv@mathworks.com with the following file attached:
    C:\Users\******\AppData\Local\Temp\matlab_crash_dump.8328

If the problem is reproducible, please submit a Service Request via:
    http://www.mathworks.com/support/contact_us/ts/help_request_1.html

A technical support engineer might contact you with further information.

Thank you for your help. MATLAB may attempt to recover, but even if recovery appears successful,
we recommend that you save your workspace and restart MATLAB as soon as possible.
 


Kann mir jemand sagen was ich falsch gemacht habe?

VG
OpiumTom
Private Nachricht senden Benutzer-Profile anzeigen


Jan S
Moderator

Moderator


Beiträge: 11.057
Anmeldedatum: 08.07.10
Wohnort: Heidelberg
Version: 2009a, 2016b
     Beitrag Verfasst am: 27.07.2010, 16:32     Titel:
  Antworten mit Zitat      
Hallo OpiumTom,

versuche doch mal, Dein Programm zu debuggen.
Lasse z.B. doch mal die zweite FOR-Schleife weg und prüfe, ob Matlab immer noch verwirrt wird.
Dann kannst Du noch anzeigen lassen, wie oft die Schleifen denn aufgerufen wird. So weit ich dass sehe, läuft i von 0 bist mrows, also mrows + 1 mal. Ist das so gewollt?

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 - 2025 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.