Thread Subject:
problems with save(...,'-struct',...) in function format

Subject: problems with save(...,'-struct',...) in function format

From: Camille Couzi

Date: 7 Apr, 2011 14:38:20

Message: 1 of 2

Hi Matlabers!
I need some help for a little problem.
I am using save function to save a matrix with a structure:

this is my matrix (for example):
matrix_example.a=12.2;
matrix_example.b='Hi!';

Now I want to save it. if I use matlab command syntax, it is:
save myexample.mat -struct matrix_example

That works fine. The thing is that I want to save matrix_example under a file name that I compose like that:

filename='myfilename.mat';

so if I write:
save filename -struct matrix_example
it works, matlab save my matrix, but under the name filename.mat, and not mysfilename.mat!!!!!!!
ie it does not go inside filename variable and takes the string inside (myfilename.mat) !!!!

how can i solve this problem?!
using function format => save (filename, ' -struct', matrix_example) ?
I get this error:
??? Error using ==> save
The argument to -STRUCT must be the name of a scalar structure variable.

Thanks in advance for your help!

Subject: problems with save(...,'-struct',...) in function format

From: Camille Couzi

Date: 7 Apr, 2011 14:48:20

Message: 2 of 2

sorry, I autorespond, I justo found the solution:
it was:
save (filename, ' -struct', 'matrix_example')
instead of:
save (filename, ' -struct', matrix_example)

!!!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
save Camille Couzi 7 Apr, 2011 10:39:07
struct Camille Couzi 7 Apr, 2011 10:39:07
function format Camille Couzi 7 Apr, 2011 10:39:07
mat file Camille Couzi 7 Apr, 2011 10:39:07
rssFeed for this Thread

Contact us