フィルターのクリア

how to link between function

3 ビュー (過去 30 日間)
muhammad ismat
muhammad ismat 2015 年 7 月 13 日
コメント済み: Stephen23 2015 年 7 月 15 日
if i use division function to calculate training and test variable as follow
function [training,test]=division(a)
number_elements = round(0.9 * length(a));
number_elements2 = length(a) - number_elements;
row_selection = randperm(size(a,1));
training = a(row_selection(1:number_elements),:)
test = a(row_selection(number_elements + number_elements2),:)
end
how to use result of the variable 'training' in other function, i.e how to pass specific result between different function.
  1 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 7 月 13 日
muhammad - which other function do you want to pass the training output to?

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

回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 7 月 15 日

noman shah
noman shah 2015 年 7 月 14 日
編集済み: noman shah 2015 年 7 月 14 日
introduce a global variable and store the data into it now use that global variable in other function. syntax "global new" (without quotation marks) will introduce a variable named "new" so that you can use this in all functions.
"Ordinarily, each MATLAB function has its own local variables, which are separate from those of other functions, and from those of the base workspace. However, if several functions, and possibly the base workspace, all declare a particular name as global, they all share a single copy of that variable. Any assignment to that variable, in any function, is available to all the functions declaring it global." (source: MATLAB help)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by