Changing the declaration of a function?
이전 댓글 표시
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
John D'Errico
2016년 7월 8일
Oh, come on. Learn to use MATLAB. How many questions can you ask about the same function? In this case, learn to pass in parameters into a function. That merely means you need to learn to use function handles, something you should have learned several questions ago.
Image Analyst
2016년 7월 8일
Then how about this:
function mFunction(alpha,beta)
return;
That's pretty minimal, and doesn't load anything.
amine&&
2016년 7월 8일
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&&
2016년 7월 9일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!