petsc to matlab

Matthew Knepley knepley at mcs.anl.gov
Thu Mar 2 15:16:18 CST 2006


billy at dem.uminho.pt writes:

     You can save in PETSc binary format and then use $PETSC_DIR/bin/matlab/PetscBinaryRead.m
to read it in. This is the preferred way I think.

   Matt

> It creates a file with the following format and I don't know how to import this
> data into matlab.
>
> row 0: (0, -0.939141)  (1, 0.234784)  (98, 0.234784)  (288, 0.234786)  (297,
> 0.234786) 
> row 1: (0, 0.234784)  (1, -0.939141)  (2, 0.234786)  (3, 0.234786)  (107, 0.234784) 
> row 2: (1, 0.234786)  (2, -0.939134)  (4, 0.234782)  (297, 0.23478)  (305,
> 0.234786) 
> ...
>
> Billy.
>
> Quoting Matthew Knepley <knepley at mcs.anl.gov>:
>
>> billy at dem.uminho.pt writes:
>> 
>>        What goes wrong?
>> 
>>             Matt
>> 
>> > How can I save the matrix in PETSc and load it in matlab?
>> >
>> > I tried this but it does not work:
>> >
>> >
>> >   PetscViewer view;
>> >
>> >   PetscViewerCreate (PETSC_COMM_WORLD, &view);
>> >
>> >   PetscViewerSetFormat (view, PETSC_VIEWER_ASCII_MATLAB);
>> >
>> >   PetscViewerAsciiOpen(PETSC_COMM_WORLD, "matrix.mat", &view);
>> >   
>> >   MatView(A, view);
>> >
>> >   PetscViewerDestroy(view);
>> >
>> >
>> >
>> > Billy.
>> >
>> >
>> >
>> 
>> -- 
>> "Failure has a thousand explanations. Success doesn't need one" -- Sir Alec
>> Guiness
>> 
>> 
>
>
>
>

-- 
"Failure has a thousand explanations. Success doesn't need one" -- Sir Alec Guiness




More information about the petsc-users mailing list