Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
save inside a specific folder

Subject: save inside a specific folder

From: Mahmood

Date: 20 Feb, 2010 22:47:03

Message: 1 of 7

Hi all
my problem is that i want to save a file ( or a pic) inside a specific folder
say i have the script i want to use in folder named synth1 and in that folder there is a folder named memo how can i use the script to save a file inside memo folder and not in the big folder synth1

hopee my q is clear

thanks

Subject: save inside a specific folder

From: Walter Roberson

Date: 20 Feb, 2010 22:53:33

Message: 2 of 7

Mahmood wrote:
> Hi all
> my problem is that i want to save a file ( or a pic) inside a specific
> folder say i have the script i want to use in folder named synth1 and in
> that folder there is a folder named memo how can i use the script to
> save a file inside memo folder and not in the big folder synth1
> hopee my q is clear
> thanks

OutputName = 'fizz7813';
save(['synth1/memo/' OutputName '.mat'], 'Var1', 'Var2');
saveas(FigureNumber, ['synth1/memo/' OutputName '.jpg']);

Subject: save inside a specific folder

From: Mahmood

Date: 20 Feb, 2010 23:10:06

Message: 3 of 7

Walter Roberson <roberson@hushmail.com> wrote in message <hlpp5d$c26$1@canopus.cc.umanitoba.ca>...
> Mahmood wrote:
> > Hi all
> > my problem is that i want to save a file ( or a pic) inside a specific
> > folder say i have the script i want to use in folder named synth1 and in
> > that folder there is a folder named memo how can i use the script to
> > save a file inside memo folder and not in the big folder synth1
> > hopee my q is clear
> > thanks
>
> OutputName = 'fizz7813';
> save(['synth1/memo/' OutputName '.mat'], 'Var1', 'Var2');
> saveas(FigureNumber, ['synth1/memo/' OutputName '.jpg']);

thanks
what if i want to read data from two folders ( named m1 and m2 ) and use this data in a script in the big folder synth1

is that possible ?

thanks

Subject: save inside a specific folder

From: Sadik

Date: 20 Feb, 2010 23:23:02

Message: 4 of 7

Hi Mahmood,

It is always possible. As long as you type in the absolute path of the folder, you don't have anything to worry about the location of your script.

Example:

Your script is in C:\synth1

Your folder is D:\Data\m1\

Then, you will feed every single function with the absolute [that is, full] folder or file path like this:

load('D:\Data\m1\myWorkspace.mat');

Hint: You can concatenate strings to arrive at your absolute path. For instance, if you would like to load myWorkspace1, myWorkspace2, ..., myWorkspace10 one after the other, you can say:

for k = 1:10
    load(['D:\Data\m1\myWorkspace' num2str(k) '.mat']);
    % Do what you want with the data in myWorkspacek.mat
end

Best.





"Mahmood " <tornido2@hotmail.com> wrote in message <hlpq4e$i5d$1@fred.mathworks.com>...
> Walter Roberson <roberson@hushmail.com> wrote in message <hlpp5d$c26$1@canopus.cc.umanitoba.ca>...
> > Mahmood wrote:
> > > Hi all
> > > my problem is that i want to save a file ( or a pic) inside a specific
> > > folder say i have the script i want to use in folder named synth1 and in
> > > that folder there is a folder named memo how can i use the script to
> > > save a file inside memo folder and not in the big folder synth1
> > > hopee my q is clear
> > > thanks
> >
> > OutputName = 'fizz7813';
> > save(['synth1/memo/' OutputName '.mat'], 'Var1', 'Var2');
> > saveas(FigureNumber, ['synth1/memo/' OutputName '.jpg']);
>
> thanks
> what if i want to read data from two folders ( named m1 and m2 ) and use this data in a script in the big folder synth1
>
> is that possible ?
>
> thanks

Subject: save inside a specific folder

From: ImageAnalyst

Date: 21 Feb, 2010 00:04:28

Message: 5 of 7

Mahmood:
You might find sprintf() useful for building up filenames. You can
also use fullfile(). You can use fileparts() to split apart
filenames.

To read files, you can also use fread(), textscan(), and dlmread().
There are many other useful string manipulation utilities that you
should at least know exist, so you might browse the help -- especially
surf the "See also" sections at the bottoms of the pages.

Subject: save inside a specific folder

From: Mahmood

Date: 21 Feb, 2010 00:17:02

Message: 6 of 7

thanks for your help
d u know how to save to a path with many variables
example :

i have a script that saves a file with 10 variables
the command is
save ('a.txt','s','n',.....)

how can i set a path to save this file in a folder named ,say, leg1
i tried
savepath leg1/('a.txt','s','n',.....)
did not work

any help ???
cheers
i have
"Sadik " <sadik.hava@gmail.com> wrote in message <hlpqsm$4i9$1@fred.mathworks.com>...
> Hi Mahmood,
>
> It is always possible. As long as you type in the absolute path of the folder, you don't have anything to worry about the location of your script.
>
> Example:
>
> Your script is in C:\synth1
>
> Your folder is D:\Data\m1\
>
> Then, you will feed every single function with the absolute [that is, full] folder or file path like this:
>
> load('D:\Data\m1\myWorkspace.mat');
>
> Hint: You can concatenate strings to arrive at your absolute path. For instance, if you would like to load myWorkspace1, myWorkspace2, ..., myWorkspace10 one after the other, you can say:
>
> for k = 1:10
> load(['D:\Data\m1\myWorkspace' num2str(k) '.mat']);
> % Do what you want with the data in myWorkspacek.mat
> end
>
> Best.
>
>
>
>
>
> "Mahmood " <tornido2@hotmail.com> wrote in message <hlpq4e$i5d$1@fred.mathworks.com>...
> > Walter Roberson <roberson@hushmail.com> wrote in message <hlpp5d$c26$1@canopus.cc.umanitoba.ca>...
> > > Mahmood wrote:
> > > > Hi all
> > > > my problem is that i want to save a file ( or a pic) inside a specific
> > > > folder say i have the script i want to use in folder named synth1 and in
> > > > that folder there is a folder named memo how can i use the script to
> > > > save a file inside memo folder and not in the big folder synth1
> > > > hopee my q is clear
> > > > thanks
> > >
> > > OutputName = 'fizz7813';
> > > save(['synth1/memo/' OutputName '.mat'], 'Var1', 'Var2');
> > > saveas(FigureNumber, ['synth1/memo/' OutputName '.jpg']);
> >
> > thanks
> > what if i want to read data from two folders ( named m1 and m2 ) and use this data in a script in the big folder synth1
> >
> > is that possible ?
> >
> > thanks

Subject: save inside a specific folder

From: ImageAnalyst

Date: 21 Feb, 2010 05:02:05

Message: 7 of 7

Mahmood:
You need to learn to read the documentation.
save() saves a file.
savepath() saves a search path.
You can't do this:
        savepath leg1/('a.txt','s','n',.....)
It doesn't make any sense.
So what are you asking?

How about this:

fullFileName = fullfile('c:\leg1', 'a.mat');
save(fullFileName, 's', 'n');

It's all spelled out there in the documentation for those two
functions.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us