Version (1011 Bytes) by Chen Qi
Save variables in the current workspace (for example: in function) to base workspace and rename them


Updated Thu, 11 Jun 2015 15:31:22 +0000

View License

This function is useful in several aspects:
1. when you debug your program, you can save any variables in your function to base workspace and compared them by just add save_to_base line in your function. You can rename them when you save them so every run you will get different names for same variables in your base workspace.
2. It can be set to a button's callback in GUI so you can let user to save GUI data into base workspace.

3. When you do script programming using a function in order to avoid namespace conflict (I always do so), some apps (such as curve fitting or distribution fitting app) may not be able to use: because they only read data from base workspace. This function lets you easily use those apps by just output the variables you need to base workspace. You can rename them when you export them into base workspace. I found script using function and export needed variables into base workspace is a perfect workflow for me to keep my base workspace clean and organized.

Cite As

Chen Qi (2023). save_to_base (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes