About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

scripts default iconputvar (Sripts) Publisher's description

(This function was suggested to me as a counterpart to the uigetvar function.)

(This function was suggested to me as a counterpart to the uigetvar function.)

The putvar tool allows you to assign a variable from a function workspace directly into the base workspace. I can envision this tool having value in one of two ways.

First, during a debugging session, one might wish to save one or more variables from the function workspace into the base workspace. This way those variables will still exist after the debugger has terminated and you have exited from the function.

A second use for this tool is as an alternative way to return a variable (or variables) from a function, possibly a GUI, during the operation of that GUI.

As an example of the operation of this code, here is a simple function that uses putvar. Note that you can provide either a variable in the workspace as input, or the name itself of the variable. Either mode of operation works.

% ==================
function testputvar
A = 3;
B = 23;
C = pi/2;
D = 'The quick brown fox jumps over the lazy dog';
% ==================

Save the function testputvar.m on your search path.

Then at the command line in MATLAB, try this. First, clear your workspace. Clear ensures that no variables exist initially in the base workspace. Then run the function testputvar, and finally execute the who command, all at the command line.

>> clear
>> testputvar
>> who

Your variables are:

The output from who tells it all. Inside the function testputvar, we had defined four variables, A, B, C, and D. But after testputvar terminates, its variables will fall into the bit bucket, disappearing into limbo. The putvar call inside testputvar ensures that the variables A, C, and D are returned into the base workspace, yet no return arguments were provided.

In the event that you wanted to assign all of the variables from the caller workspace, just do this inside your function...

W = who;

I had considered wrapping a GUI around putvar, probably called uiputvar, but I don't see much benefit there, whereas the uigetvar tool truly does need to be a GUI.

System Requirements:

MATLAB 7.10 (2010a)
Program Release Status: New Release
Program Install Support: Install and Uninstall

putvar (Sripts) Tags:

Click on a tag to find related softwares

Is putvar (Sripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.