Changing the declaration of a function?
Mostrar comentarios más antiguos
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 comentarios
John D'Errico
el 8 de Jul. de 2016
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
el 8 de Jul. de 2016
Then how about this:
function mFunction(alpha,beta)
return;
That's pretty minimal, and doesn't load anything.
amine&&
el 8 de Jul. de 2016
Image Analyst
el 9 de Jul. de 2016
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&&
el 9 de Jul. de 2016
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!