Thread View: comp.soft-sys.matlab
2 messages
2 total messages
Started by sumargoh
Tue, 26 Jan 1993 16:25
Some Questions on Matlab
Author: sumargoh
Date: Tue, 26 Jan 1993 16:25
Date: Tue, 26 Jan 1993 16:25
13 lines
1161 bytes
1161 bytes
Hi, I am currently using Matlab 3.5g on a VAX. I have some questions to ask:
1. If I use EIGS() MatLab built in function to find the eigensystem of a given matrix,
I noticed that the results obtained show that the eigenvalues are arranged in
ascending order. Is there any switch that I can use to tell the EIGS() funtion
to put out the eigenvalues in a descending order?
2. The MatLab package comes with some C source codes to read binary files and convert
them to numbers. I tried to implement a binary to number conversion using the
above mentioned C source codes with no avail. Has anyone out there ever written
such routine in C and would like to share?
Please kindly send your response to sumargoh@fiu.edu. Thank you very much.
Re: Some Questions on Matlab
Author: Brad Hedstrom
Date: Wed, 27 Jan 1993 18:45
Date: Wed, 27 Jan 1993 18:45
109 lines
4325 bytes
4325 bytes
On Tue, 26 Jan 1993 16:25:01 GMT, sumargoh@widget.fiu.edu said:
>2. The MatLab package comes with some C source codes to read binary
>files and convert them to numbers. I tried to implement a binary to
>number conversion using the above mentioned C source codes with no
>avail. Has anyone out there ever written such routine in C and would
>like to share?
Here are two C subroutines for writing floating-point and integer
Matlab binary data files. I've been using them for years on Suns and
Macs. They're pretty much right out of the Matlab manual if I remember
correctly .
file matlabbin.h
extern void fmatsave();
extern void imatsave();
file matlabbin.c
typedef struct{
long int type; /* type of file (MOPT) */
long int mrows; /* number of rows of variable */
long int ncols; /* number of colums of variable */
long int imagf; /* 0 => no imaginary part, 1 => imaginary part */
long int namlen;/* length of name string (including NULL) */
} Fmatrix;
# include <stdio.h>
# include <string.h>
/* This routine writes floating point data (matrix or vector)
in the matlab file format */
void fmatsave(real, imag, rowspace, colspace, name, fileptr)
float *real; /* real part of vector */
float *imag; /* imaginary part of vector */
int rowspace; /* number of rows of variable */
int colspace; /* number of colums of variable */
char *name; /* pointer to name of variable */
FILE *fileptr; /* pointer to destination file */
{
int mn; /* row/column counter */
Fmatrix x; /* MATLAB file data structure */
/* define constants */
x.type = 1010; /* Sun ID, column wise, float precision, numeric */
/* define the MATLAB data structure */
x.mrows = rowspace;
x.ncols = colspace;
if (imag == NULL){ /* check for existance of imaginary */
x.imagf = 0;
} else {
x.imagf = 1;
}
x.namlen = strlen(name) + 1; /* add one for NULL not counted */
/* write binary MATLAB file */
fwrite(&x, sizeof(Fmatrix), 1, fileptr);
fwrite(name, sizeof(char), x.namlen, fileptr);
mn = x.mrows * x.ncols;
fwrite(real, sizeof(float), mn, fileptr);
if (x.imagf){
fwrite(imag, sizeof(float), mn, fileptr);
}
}
/* This routine writes integer data (matrix or vector)
in the matlab file format */
void imatsave(real, imag, rowspace, colspace, name, fileptr)
int *real; /* real part of vector */
int *imag; /* imaginary part of vector */
int rowspace; /* number of rows of variable */
int colspace; /* number of colums of variable */
char *name; /* pointer to name of variable */
FILE *fileptr; /* pointer to destination file */
{
int mn; /* row/column counter */
Fmatrix x; /* MATLAB file data structure */
/* define constants */
x.type = 1020; /* Sun ID, column wise, float precision, numeric */
/* define the MATLAB data structure */
x.mrows = rowspace;
x.ncols = colspace;
if (imag == NULL){ /* check for existance of imaginary */
x.imagf = 0;
} else {
x.imagf = 1;
}
x.namlen = strlen(name) + 1; /* add one for NULL not counted */
/* write binary MATLAB file */
fwrite(&x, sizeof(Fmatrix), 1, fileptr);
fwrite(name, sizeof(char), x.namlen, fileptr);
mn = x.mrows * x.ncols;
fwrite(real, sizeof(int), mn, fileptr);
if (x.imagf){
fwrite(imag, sizeof(int), mn, fileptr);
}
}
--
___________________________________________________________________________
Brad Hedstrom: Grad Student, Research Assistant | Elec. & Comp. Engr. Dept.
Also `Consultant to the Stars' in: | University of Victoria
DSP, LabVIEW, Networking, Sun, and Macintosh | Victoria, B.C., Canada
Internet: hedstrom@sirius.UVic.CA | (a.k.a. Brazil North)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads