フィルターのクリア

mat-file

3 ビュー (過去 30 日間)
saloni singhal
saloni singhal 2012 年 5 月 30 日
sir,
I want to save whole function in mat -file
i tried like this:
function function11 function sal r = 1;s = 1; d = r+s; b = r-s; return end save('first.mat','sal'); end
But this is not working.So, is there any other way to do that.so that if i type sal on command window .I should get like this
sal= r = 1;s = 1; d = r+s; b = r-s;
thank you

回答 (2 件)

Thomas
Thomas 2012 年 5 月 30 日
You do not save a function in *.mat file. you save a function in an *.m file
mat files are used to store the variable data..
for your example above only do the following
function sal
r = 1
s = 1
d = r+s
b = r-s
Save the above fucntion as sal.m
when you run on the command line >> sal
r = 1.00
s = 1.00
d = 2.00
b = 0

saloni singhal
saloni singhal 2012 年 5 月 30 日
But sir i saw one program in which they have stored value of mat3 which is equal to
h2 = findobj('tag','sl2');
handles2;
str = get(h2,'string');
Po1 = str2double(str);
main2;
this mat3 is stored in mat file and after load the mat file if i type mat3
i am getting
mat = h2 = findobj('tag','sl2'); handles2; str = get(h2,'string'); Po1 = str2double(str); main2;
i want to use this in my program but i am not able to do that
please help me
thank you
  2 件のコメント
Thomas
Thomas 2012 年 5 月 30 日
I don't think what you describe is correct..
you can only save and load variables from *.mat file. You want your code coming from a mat file which is not possible unless you store the variables as strings and then call them back.
Thomas
Thomas 2012 年 5 月 30 日
in that case you need:
h2={'findobj(''tag'',''sl2'');'};
save('first.mat','h2');
now to load this back
load('first.mat')
h2

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by