Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

to edit a variable of mat file

933 views
Skip to first unread message

Darshana

unread,
Mar 20, 2009, 4:12:01 AM3/20/09
to
Hello,
I want to edit variables of mat file.Is it possible?if possible then how can we do?
thanks,
Darshana Mistry

us

unread,
Mar 20, 2009, 5:24:01 AM3/20/09
to
"Darshana"
> I want to edit variables of mat file.Is it possible?if possible then how can we do...

the one of the solutions

% assume you want to change the var V, eg, 1x10 doubles,
% which lives in file MYFILE.MAT
fnam='myfile';
mv=load(fnam);
v=mv.v;
v(1)=10; % <- keep rest of V...
save(fnam,'v');

us

Darshana

unread,
Mar 20, 2009, 5:47:01 AM3/20/09
to
Hello,
i done as your solution.but it's replace as only change variable...in brief description, I have 1.mat file which have p1,p2,X,Y,ker,C variables. now I change X variable as your give solution.now I save this file.and when I see 1.mat file then it has only one variable
X. so my original file is change with change variable.

so tell me how can I solve this problem?
thanks,
Darshana Mistry
"us " <u...@neurol.unizh.ch> wrote in message <gpvnbh$5k5$1...@fred.mathworks.com>...

us

unread,
Mar 20, 2009, 6:31:01 AM3/20/09
to
"Darshana"

> i done as your solution.but it's replace as only change variable...in brief description, I have 1.mat file which have p1,p2,X,Y,ker,C variables. now I change X variable as your give solution.now I save this file.and when I see 1.mat file then it has only one variable
> X. so my original file is change with change variable...

sorry for having misunderstood your OP...
to change one var and keep others, do this

fnam='foo.mat';
whos('-file',fnam); % see what you have...
mv=load(fnam);
mv.v=pi;
save(fnam,'-struct','mv'); % <- save each field of MV as a var
whos('-file',fnam); % tells you, that vars are saved individually...
% for an explanation, see
help save;

us

Ashish Uthama

unread,
Mar 23, 2009, 11:32:28 AM3/23/09
to
On Fri, 20 Mar 2009 05:47:01 -0400, Darshana <mail...@astrology.com>
wrote:


You could also look into the '-append' option to SAVE.

0 new messages