Got Questions? Get Answers.
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:
Workspace issues

Subject: Workspace issues

From: Hugh

Date: 12 Oct, 2012 17:14:11

Message: 1 of 3

Hi there,

I imported some data and them cleaned it up, there is a lot of data so this is quite time consuming.

I then wrote a script that uses these variables.

However when I went to run the script, it says that these varibles are not know. In the workspace editor is only shows variables declared in the script.

Q1.) Is there a way to get the original variables back?

Secondly as the clean up operation takes quite some time I don't want to have to import that data and clean in every time I run the M-file.

Q2.) So once I have the cleaned data how do I make these variables available to an M file (do I have to declare them as global or something like that?)
 

Subject: Workspace issues

From: Hugh

Date: 12 Oct, 2012 17:55:14

Message: 2 of 3

To add, I initially thought the problem was that I had tried to debug the script file, without calling it from the commend window and that's why I didn't have access to the base workspace variables.

But I just tried it again this time calling it from the command window (with a test data set) and the same thing happened?




"Hugh" wrote in message <k59j53$sqp$1@newscl01ah.mathworks.com>...
> Hi there,
>
> I imported some data and them cleaned it up, there is a lot of data so this is quite time consuming.
>
> I then wrote a script that uses these variables.
>
> However when I went to run the script, it says that these varibles are not know. In the workspace editor is only shows variables declared in the script.
>
> Q1.) Is there a way to get the original variables back?
>
> Secondly as the clean up operation takes quite some time I don't want to have to import that data and clean in every time I run the M-file.
>
> Q2.) So once I have the cleaned data how do I make these variables available to an M file (do I have to declare them as global or something like that?)
>

Subject: Workspace issues

From: dpb

Date: 12 Oct, 2012 18:38:04

Message: 3 of 3

On 10/12/2012 12:14 PM, Hugh wrote:
...

> I imported some data and them cleaned it up, there is a lot of data so
> this is quite time consuming.

Well, once you've done that, SAVE them (and, perhaps do so incrementally
to save the work to date just in case)...then, at worst, whatever you do
(other than overwriting or deleting the file) you simply reLOAD them back...

> I then wrote a script that uses these variables.
>
> However when I went to run the script, it says that these varibles are
> not know. In the workspace editor is only shows variables declared in
> the script.
>
> Q1.) Is there a way to get the original variables back?
>
> Secondly as the clean up operation takes quite some time I don't want to
> have to import that data and clean in every time I run the M-file.
>
> Q2.) So once I have the cleaned data how do I make these variables
> available to an M file (do I have to declare them as global or something
> like that?)

Can't see what you actually did so can't really say--one might guess you
maybe did a CLEAR at some time? _FAR_ too many scripts we see posted
from newbies have such a thing at the beginning of them. See above for
the how to not lose your work...and, btw, unless this is some "ad hoc"
cleanup process, it's highly likely you could automate it as well...

If it is a script (not a function) then it has access to the workplace
environment since it runs in that namespace. As noted above, unless you
either did a CLEAR or used a different name (Matlab _is_ case-sensitive,
for example) there should be no problem whatsoever. A function m-file
otoh, has its own namespace and you need to pass variables to it.

See the Getting Started section on scripts and functions for more
details. If this doesn't solve the problem post some actual
code/workplace operations that seem to cause the problem for evaluation.

--

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