load function

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

load function

taquito
Hi! I'm trying to load a file called '200'. If I write A=load('200'), the
file is loaded without problems.

If define
a=200;
A=load('a');

it doesn't work. This messagge appear: error: load: unable to find file a.

How can I solve it? Thanks!



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: load function

Mono Brezel
Hi Taquito,


I guess you need to define your variable as string and then just load it.


a = '200';
A =load(a);


I am currently not at my desk, give it a try...hope it works.


taquito <[hidden email]> schrieb am Sa., 21. Dez. 2019, 13:56:
Hi! I'm trying to load a file called '200'. If I write A=load('200'), the
file is loaded without problems.

If define
a=200;
A=load('a');

it doesn't work. This messagge appear: error: load: unable to find file a.

How can I solve it? Thanks!



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html




Reply | Threaded
Open this post in threaded view
|

Re: load function

BGreen

On Sat, Dec 21, 2019, 2:01 AM Mono Brezel <[hidden email]> wrote:
Hi Taquito,


I guess you need to define your variable as string and then just load it.


a = '200';
A =load(a);


I am currently not at my desk, give it a try...hope it works.


taquito <[hidden email]> schrieb am Sa., 21. Dez. 2019, 13:56:
Hi! I'm trying to load a file called '200'. If I write A=load('200'), the
file is loaded without problems.

If define 
a=200;
A=load('a');

it doesn't work. This messagge appear: error: load: unable to find file a.

How can I solve it? Thanks!



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Mono is right, the argument you gave was the character "a", not the value assigned it as a variable. You can convert numbers to string using "num2str". For example:

a=200;
A=load(num2str(a));


Reply | Threaded
Open this post in threaded view
|

Re: load function

taquito
Yes, you both are right, thanks!



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: load function

BGreen
On Sat, Dec 21, 2019, 9:35 AM taquito <[hidden email]> wrote:
Yes, you both are right, thanks!

--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


You're welcome!