フィルターのクリア

Changing the declaration of a function?

1 回表示 (過去 30 日間)
amine&&
amine&& 2016 年 7 月 8 日
コメント済み: Walter Roberson 2016 年 7 月 11 日
I have a following function that begins with:
function X=mFunction(alpha,beta)
%%load the dataset
filename = 'Bo_1.xlsx';
y = xlsread(filename);
yS=y(1:288);
I want to minimize it. But without load data every time..
How I should proceed?
Thanks!
  5 件のコメント
Image Analyst
Image Analyst 2016 年 7 月 9 日
You said you wanted to minimize it, so I just threw out everything that wasn't absolutely needed for the function to run. You assign a filename and read in a workbook but don't actually return it to your calling function, so I got rid of that unneeded part. From your comment later to Walter it sounds like you don't even know what alpha and beta are, so you might not need those either, and the function could be simplified even more - just don't have any input arguments. Now you'll have a function that does absolutely nothing - about as minimal as you can get.
amine&&
amine&& 2016 年 7 月 9 日
Ok Image Analyst, it is very interesting what you say I'll take it in concideration. Thanks!

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

採用された回答

Walter Roberson
Walter Roberson 2016 年 7 月 8 日
function run_my_plot
alpha = ....
beta = ....
filename = 'Bo_1.xlsx';
y = xlsread(filename);
yS=y(1:288);
X = arrayfun(alpha, beta, yS);
surf(alpha, beta, X, 'edgecolor', 'none');
function X = mFunction(alpha, beta, yS)
.... code with no load() goes here
  10 件のコメント
amine&&
amine&& 2016 年 7 月 10 日
How can i get "current function value" giving by Optimization tool using only the command line. Thanks
Walter Roberson
Walter Roberson 2016 年 7 月 11 日
That is a question that has nothing to do with this topic. Fortunately you have already opened a new Question about it, which has been replied to.

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

その他の回答 (0 件)

カテゴリ

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