How to display a variable in workspace before the end of the script?

4 visualizzazioni (ultimi 30 giorni)
I have a script that runs one task of my data analysis. The script starts off by specifying variables (ex. CLMG2 and VLMG2) from columns in a matrix. It then pauses, where I (want to) manually create a multi-series figure with CLMG2 and VLMG2, and then visually select data points from this figure to create a new variable (ex. RED3). The rest of this script then uses variable RED3 to make other graphs.
There is nothing wrong with my code (individually it all works), but when I run the whole script and it gets to the pause, I do not see my variables CLMG2 and VLMG2, which were created before the pause. I need them to create the figure by hand etc., which is a problem if I don't see them. I believe it is not displaying the variables because MATLAB waits until then end of the script (or end of whatever you told it to run, in this case a script) before displaying the variables it created? Is there a way to display them in the workspace before the end or as it creates them? or is there another solution to this problem?
Note: I am not running any functions before the pause. Here is my code up until the pause, and a little after. (I import matrix MA from a file).
A = MA(MA(:,5) == 10010,:);
PITCH=A(:,10);
ROLL=A(:,11);
YAW=A(:,12);
CLMG2=A(:,8);
ILMGC=A(:,7);
VLMG2=A(:,9);
ANG=A(:,6);
RALT=A(:,4);
%%Create Figure and Create Variables
% By hand. Program will pause for 2 minutes
pause on
pause(120)
%%With New Variables Created From Graph
mcl=mean(RED3(:,2));
scl=RED3(:,2)-mcl;
fs = 10; % Sample frequency (Hz)
m = length(scl); % Window length
n = pow2(nextpow2(m)); % Transform length
Y = fft(scl,n)/m; % DFT
c = fs/2*linspace(0,1,n/2+1);
cc=2*abs(Y(1:n/2+1));
Name=strcat('CLMG Profile of Line',an);
FourierProfile(c,cc,RED3(:,2),Name)
  2 Commenti
dpb
dpb il 9 Ott 2013
Need code structure -- sounds like perhaps your script is calling a function that does the work, perhaps, so the variables you've created aren't in the base workspace but local to the function. But, can't tell that for certain w/o seeing the structure of your code.
Won't need all of it but do need to see the top-level script outline 'til get to the pause and how you've done that, specifically.
Lindsay
Lindsay il 15 Ott 2013
I posted some code. Also, I am not calling a function before the pause.
"dpb on 9 Oct 2013 at 18:49 Need code structure -- sounds like perhaps your script is calling a function that does the work, perhaps, so the variables you've created aren't in the base workspace but local to the function. But, can't tell that for certain w/o seeing the structure of your code.
Won't need all of it but do need to see the top-level script outline 'til get to the pause and how you've done that, specifically."

Accedi per commentare.

Risposte (1)

Yatin
Yatin il 14 Ott 2013
Hi, It is possible that you are creating the variables locally in a fuction which your script is calling. Hence, when the function returns, the variables go out of scope and are not visible in your workspace.
You can however save the variables to a file once you create them in order to view their contents or load them from the file at a later point in time. May be the link will be helpful. Also, I would recommend debugging your code in order to determine what is happening exactly.

Categorie

Scopri di più su Variables in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by