www.vorhilfe.de
- Förderverein -
Der Förderverein.

Gemeinnütziger Verein zur Finanzierung des Projekts Vorhilfe.de.
Hallo Gast!einloggen | registrieren ]
Startseite · Mitglieder · Impressum
Forenbaum
^ Forenbaum
Status VH e.V.
  Status Vereinsforum

Gezeigt werden alle Foren bis zur Tiefe 2

Navigation
 Startseite...
 Suchen
 Impressum
Das Projekt
Server und Internetanbindung werden durch Spenden finanziert.
Organisiert wird das Projekt von unserem Koordinatorenteam.
Hunderte Mitglieder helfen ehrenamtlich in unseren moderierten Foren.
Anbieter der Seite ist der gemeinnützige Verein "Vorhilfe.de e.V.".
Partnerseiten
Weitere Fächer:

Open Source FunktionenplotterFunkyPlot: Kostenloser und quelloffener Funktionenplotter für Linux und andere Betriebssysteme
Forum "C/C++" - .mat Datei in c++ einfügen
.mat Datei in c++ einfügen < C/C++ < Programmiersprachen < Praxis < Informatik < Vorhilfe
Ansicht: [ geschachtelt ] | ^ Forum "C/C++"  | ^^ Alle Foren  | ^ Forenbaum  | Materialien

.mat Datei in c++ einfügen: .mat Datei in c einfügen
Status: (Frage) überfällig Status 
Datum: 17:20 Do 29.05.2008
Autor: Jtosik

Aufgabe
#include "stdafx.h"
#include "matrix.h"
#include <stdio.h>
#include <stdlib.h>
#include <mat.h>

#pragma comment(lib, "libmat.lib")
#pragma comment(lib, "libmx.lib")

const char *filename="C: [mm] \backslash \backslash [/mm] Documents and Settings [mm] \backslash \backslasht [/mm] j72si0 backslash [mm] \backslash [/mm] VS [mm] \backslash \backslash ASM\_20080118\_113904\_Edik\_OpelBumper.mat"; [/mm]

int diagnose(const char *file) {
  MATFile *pmat;
  const char **dir;
  const char *name;
  int   ndir;
  int   i;
  mxArray *pa;

  printf("Reading file [mm] \%s...\backslash [/mm] n [mm] \backslash [/mm] n", file);

  /*
   * Open file to get directory
   */
  pmat = matOpen(file, "r");
  if (pmat == NULL) {
    printf("Error opening file [mm] \%s \backslash [/mm] n", file);
    return(1);
  }
  
  /*
   * get directory of MAT-file
   */
  dir = (const char **)matGetDir(pmat, &ndir);
  if (dir == NULL) {
    printf("Error reading directory of file [mm] \%s \backslash [/mm] n", file);
    return(1);
  } else {
    printf("Directory of [mm] \%s: \backslash [/mm] n", file);
    for (i=0; i < ndir; i++)
      [mm] printf("\% [/mm] s [mm] \backslash [/mm] n",dir[i]);
  }
  mxFree(dir);

  /* In order to use matGetNextXXX correctly, reopen file to read in headers. */
  if (matClose(pmat) != 0) {
    printf("Error closing file [mm] \% [/mm] s [mm] \backslash [/mm] n",file);
    return(1);
  }
  pmat = matOpen(file, "r");
  if (pmat == NULL) {
    printf("Error reopening file [mm] \% [/mm] s [mm] \backslash [/mm] n", file);
    return(1);
  }

  /* Get headers of all variables */
  [mm] printf("\backslash [/mm] n Examining the header for each variable: [mm] \backslash [/mm] n");
  for (i=0; i < ndir; i++) {
    pa = matGetNextVariableInfo(pmat, &name);
    if (pa == NULL) {
printf("Error reading in file [mm] \%s \backslash [/mm] n", file);
return(1);
    }
    /* Diagnose header pa */
    printf("According to its header, array [mm] \% [/mm] s has [mm] \% [/mm] d dimensions [mm] \backslash [/mm] n",
   name, mxGetNumberOfDimensions(pa));
    if (mxIsFromGlobalWS(pa))
      printf("  and was a global variable when saved [mm] \backslash [/mm] n");
    else
      printf("  and was a local variable when saved [mm] \backslash [/mm] n");
    mxDestroyArray(pa);
  }

  /* Reopen file to read in actual arrays. */
  if (matClose(pmat) != 0) {
    printf("Error closing file [mm] \% [/mm] s [mm] \backslash [/mm] n",file);
    return(1);
  }
  pmat = matOpen(file, "r");
  if (pmat == NULL) {
    printf("Error reopening file [mm] \% [/mm] s [mm] \backslash [/mm] n", file);
    return(1);
  }

  /* Read in each array. */
  [mm] printf("\nReading [/mm] in the actual array contents: [mm] \backslash [/mm] n");
  for (i=0; i<ndir; i++) {
      pa = matGetNextVariable(pmat, [mm] \&name); [/mm]
      if (pa == NULL) {
  printf("Error reading in file [mm] %s\n", [/mm] file);
  return(1);
      }
      /*
       * Diagnose array pa
       */
      printf("According to its contents, array [mm] \%s [/mm] has [mm] \%d [/mm] dimensions [mm] \backslash [/mm] n",
     name, mxGetNumberOfDimensions(pa));
      if (mxIsFromGlobalWS(pa))
printf("  and was a global variable when saved [mm] \backslash [/mm] n");
      else
printf("  and was a local variable when saved [mm] \backslash [/mm] n");
      mxDestroyArray(pa);
  }

  if (matClose(pmat) != 0) {
      printf("Error closing file [mm] \% [/mm] s [mm] \backslash [/mm] n",file);
      return(1);
  }
  printf("Done [mm] \backslash [/mm] n");
  return(0);
}

int main(int argc, char **argv)
{
  int result;
  result=diagnose(filename);
  system("PAUSE");

  return [mm] (result==0)?EXIT\_SUCCESS:EXIT\_FAILURE; [/mm]

}

Hiii,

ich bin so ein Anfänger in C++, tut mir echt leid wegen der Frage jetzt...
Also habe eine .mat Datei jetzt mit diesem Code in C++ eingelesen. Auf diese Werte kann ich doch jetzt zugreifen oder? Das sind mehrere Array mit der Dimension 2. Wie macht man denn so etwas? Irgendetwas mit Pointern???

Danke im Voraus

Ich habe diese Frage in keinem Forum auf anderen Internetseiten gestellt.


        
Bezug
.mat Datei in c++ einfügen: Fälligkeit abgelaufen
Status: (Mitteilung) Reaktion unnötig Status 
Datum: 18:20 Sa 31.05.2008
Autor: matux

$MATUXTEXT(ueberfaellige_frage)
Bezug
Ansicht: [ geschachtelt ] | ^ Forum "C/C++"  | ^^ Alle Foren  | ^ Forenbaum  | Materialien


^ Seitenanfang ^
ev.vorhilfe.de
[ Startseite | Mitglieder | Impressum ]