matheraum.de
Raum für Mathematik
Offene Informations- und Nachhilfegemeinschaft

Für Schüler, Studenten, Lehrer, Mathematik-Interessierte.
Hallo Gast!einloggen | registrieren ]
Startseite · Forum · Wissen · Kurse · Mitglieder · Team · Impressum
Forenbaum
^ Forenbaum
Status Mathe
  Status Schulmathe
    Status Primarstufe
    Status Mathe Klassen 5-7
    Status Mathe Klassen 8-10
    Status Oberstufenmathe
    Status Mathe-Wettbewerbe
    Status Sonstiges
  Status Hochschulmathe
    Status Uni-Analysis
    Status Uni-Lin. Algebra
    Status Algebra+Zahlentheo.
    Status Diskrete Mathematik
    Status Fachdidaktik
    Status Finanz+Versicherung
    Status Logik+Mengenlehre
    Status Numerik
    Status Uni-Stochastik
    Status Topologie+Geometrie
    Status Uni-Sonstiges
  Status Mathe-Vorkurse
    Status Organisatorisches
    Status Schule
    Status Universität
  Status Mathe-Software
    Status Derive
    Status DynaGeo
    Status FunkyPlot
    Status GeoGebra
    Status LaTeX
    Status Maple
    Status MathCad
    Status Mathematica
    Status Matlab
    Status Maxima
    Status MuPad
    Status Taschenrechner

Gezeigt werden alle Foren bis zur Tiefe 2

Navigation
 Startseite...
 Neuerdings beta neu
 Forum...
 vorwissen...
 vorkurse...
 Werkzeuge...
 Nachhilfevermittlung beta...
 Online-Spiele beta
 Suchen
 Verein...
 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
Dt. Schulen im Ausland: Mathe-Seiten:Weitere Fächer:

Open Source FunktionenplotterFunkyPlot: Kostenloser und quelloffener Funktionenplotter für Linux und andere Betriebssysteme
StartseiteMatheForenC/C++.mat Datei in c++ einfügen
Foren für weitere Schulfächer findest Du auf www.vorhilfe.de z.B. Geschichte • Erdkunde • Sozialwissenschaften • Politik/Wirtschaft
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 ^
www.matheraum.de
[ Startseite | Forum | Wissen | Kurse | Mitglieder | Team | Impressum ]