Discussion:
using save command to save in other directory
(too old to reply)
Christine
2009-07-22 06:01:09 UTC
Permalink
I want to use the ' save ' command to save a variable.

currently i am using the below method,

a = [1 2 3];
save a.mat a

Can I change the directory that I want to save? coz, I realise that it save in the folder that I am using?

Is there way to save a variable in the destination that I want?

pls help.
Shanmugam Kannappan
2009-07-22 06:19:02 UTC
Permalink
Post by Christine
I want to use the ' save ' command to save a variable.
currently i am using the below method,
a = [1 2 3];
save a.mat a
Can I change the directory that I want to save? coz, I realise that it save in the folder that I am using?
Is there way to save a variable in the destination that I want?
pls help.
Hi!
you can.....
Just include the path in the file name itself....
ex: save C:\MATLAB\R2007bNew\New folder\filename variable
Shan.........
Christine
2009-07-22 06:23:02 UTC
Permalink
Replying to Shanmugam Kannappan,

i have tried

save c:/a.mat a

it ends up with an error

??? Error using ==> save
Unable to write file c:/a.mat: permission denied.

Permission denied? i am using windows vista now. How to overcome this error?

Thks Shanmugam Kannappan, i think it is my windows vista problem to have the permission to write the file in a particular directory, I guess so.

pls help..
Shanmugam Kannappan
2009-07-22 06:34:03 UTC
Permalink
Post by Christine
Replying to Shanmugam Kannappan,
i have tried
save c:/a.mat a
it ends up with an error
??? Error using ==> save
Unable to write file c:/a.mat: permission denied.
Permission denied? i am using windows vista now. How to overcome this error?
Thks Shanmugam Kannappan, i think it is my windows vista problem to have the permission to write the file in a particular directory, I guess so.
pls help..
Hi!
You are right.
Its in read/write permission in your system.
Ask your administrator to provide write permission to C drive & try......
Shan.....
Shanmugam Kannappan
2009-07-22 06:43:04 UTC
Permalink
Post by Shanmugam Kannappan
Post by Christine
Replying to Shanmugam Kannappan,
i have tried
save c:/a.mat a
it ends up with an error
??? Error using ==> save
Unable to write file c:/a.mat: permission denied.
Permission denied? i am using windows vista now. How to overcome this error?
Thks Shanmugam Kannappan, i think it is my windows vista problem to have the permission to write the file in a particular directory, I guess so.
pls help..
Hi!
You are right.
Its in read/write permission in your system.
Ask your administrator to provide write permission to C drive & try......
Shan.....
Hi!
Also make a note that if your path has space
ex:
C:\My folder\filename
you have to use like
save('C:\My folder\filename','varname')

Shan.......
Christine
2009-07-22 06:49:04 UTC
Permalink
problem solved. Solution:

For Vista user,
1. Open Control Panel.
2. Under User Account and Family settings click on the "Add or remove user account".
3. Under the user account click on the "Go to the main User Account page" link.
In the "Turn on User Account Control (UAC) to make your computer more secure" click to unselect the "Use User Account Control (UAC) to help protect your computer". Click on the Ok button.
4. You will be prompted to reboot your computer. Do so when ready.
Pedro
2009-11-01 23:17:03 UTC
Permalink
Hello Cristine, i do what you said and it worked, but only work in localhost!
When i put this in a server, i got the same error!
Any ideia?
Thanks
Post by Christine
For Vista user,
1. Open Control Panel.
2. Under User Account and Family settings click on the "Add or remove user account".
3. Under the user account click on the "Go to the main User Account page" link.
In the "Turn on User Account Control (UAC) to make your computer more secure" click to unselect the "Use User Account Control (UAC) to help protect your computer". Click on the Ok button.
4. You will be prompted to reboot your computer. Do so when ready.
N
2013-01-15 12:42:10 UTC
Permalink
Post by Shanmugam Kannappan
Post by Christine
I want to use the ' save ' command to save a variable.
currently i am using the below method,
a = [1 2 3];
save a.mat a
Can I change the directory that I want to save? coz, I realise that it save in the folder that I am using?
Is there way to save a variable in the destination that I want?
pls help.
Hi!
you can.....
Just include the path in the file name itself....
ex: save C:\MATLAB\R2007bNew\New folder\filename variable
I load files with different names and run my algorithm. I wan to save the result in a file with the same name as the data that I have loaded, but I do not want to change the file name in save command every time. i. e.

c = num2str('nn');
d = num2str('.txt');
e = strcat(c,d);
a = load(e);
b = a^2;

save D:/data/... b

I want to save b in a file which is called ,nn, but if I put there e, it will be saved as a file called e. How should I make it to save it in a file called nn without changing it manually?

Thanks in advance.
Post by Shanmugam Kannappan
Shan.........
Steven_Lord
2013-01-15 15:09:53 UTC
Permalink
"N " <***@yahoo.com> wrote in message news:kd3ir2$8t6$***@newscl01ah.mathworks.com...

*snip*
Post by N
I want to save b in a file which is called ,nn, but if I put there e, it
will be saved as a file called e. How should I make it to save it in a
file called nn without changing it manually?
filename = 'myfile.mat';
x = 1;

% Saves the variable x into a file whose name is filename.mat
save filename x

% Saves the variable x into a file whose name is filename.mat
save('filename', 'x')

% Saves the variable x into a file whose name is stored in the variable
filename.
% In this case the file will be named myfile.mat.
save(filename, 'x')

You're using the first syntax I demonstrated. Use the third syntax instead.
--
Steve Lord
***@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
Christine
2009-07-22 06:20:20 UTC
Permalink
Say,

the current directory that i am using now is

C:/work

it will be save in c:/work/a.mat

but i wan to save the a.mat file in

c:/

means

c:/a.mat

Pls tk note that i wan to save the variable only (in .mat file).
Loading...