Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

How to store, write and call in another program ?

1 view (last 30 days)
I would like to know, how to store a particular variable in a file ? after that, I have to call that variable in an another program, so how to do that ?
[EDITED, Jan] Copied from comment section, because information needed to define the question exactly, should be found in the question. I've removed the request for the mail address, because this does not match the nature of the forum.
In one program: I wrote down a function. Please find below a part of the program:
[n, bc] = hist(im,31); % n is the number of occurrence in each bin
% and bc are the bin centers
p = n/sum(n); % normalize occurrences to create estimate of PDF
figure(3), bar(bc, p) title('PDF estimate of 1st formants');
xlabel('standard deviation'); ylabel('no. of occurence');
bc is a 1*31 double,
I have to store bc first and call this in another .m program..
So I need to know, how to store the bc(1*31) and then call it in another .m program.
  2 Comments
Jan
Jan on 9 Jul 2012
Please post more details. Does "another program" mean another M-function or a program like Excel?

Answers (1)

Conrad
Conrad on 9 Jul 2012
Edited: Jan on 9 Jul 2012
Hi Tarun, something like this:
myVariable = 1; % Assign value to variable.
save myVariable.mat myVariable; % Save to *.mat file.
In your 2nd program:
load myVariable.mat; % Load *.mat file.
Type "help save" in MATLAB for more information.
Or did you mean accessing the data in a program different from MATLAB?
Conrad
[EDITED, Jan, code formatted]
  1 Comment
Jan
Jan on 9 Jul 2012
It is safer to specify the full path of the file, e.g. "D:\Temp\myVariable.mat", because the other function could have changed the current folder.

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!