I have a question about the function in the class. I have main.m and my_class.m . my_class has following function,
classdef my_class ... function [x,y,z,w] = get_File(pathname,filename) completename = fullfile(pathname,filename); data = load(completename); x = data(:,1); y = data(:,2); ..... endend
here simply trying to load the file from pathname and filename as input. But when main.m tries to include this function by
pathname = 'my pathname';filename = 'my filename';obj = my_class;[a,b,c,d] = obj.get_File(pathname,filename);
error shows up as follows
Error using my_class/get_FileToo many input arguments.Error in Untitled (line 4)[a,b,c,d] = obj.get_File(pathname,filename);
Seems this error will disappear if I set the function as
function [x,y,z,w] = get_File(~,~) %<--- here its changed
pathname = 'my pathname'; filename = 'my filename'; completename = fullfile(pathname,filename); data = load(completename); x = data(:,1); y = data(:,2); .....end
and include in main.m like
obj = Tomography_Tool;[a,b,c,d] = obj.get_File;
can anybody explain why I got the error and disappear by this modification?
thank you for your help,
Best Answer