Why do i keep on getting error 'Not enough input arguments' on calling the function?
Ältere Kommentare anzeigen
I want to create a table of values of certain lengths (indices stored as indices )from a vector. For that I create an empty table and then later insert these values inside that. This works in the code, but when I try to make a function, it gives an error, "Not enough input arguments."
The working code is given below
clc
clear all
close all
Data= load('array.mat');
array = Data.array
indices = [4 80 99 143 166 197 204 250 295 350 385 400 467 554];
lengthx = length(indices);
lengthy = height(array);
extracted = NaN([lengthy lengthx]);
extracted = array2table(extracted);
for i = 1:lengthx
num = indices(i);
a = array(1:num);
padding = lengthy-height(a);
extracted(:,i)= array2table(padarray(a,padding,NaN,'post'));
end
Now, I try to make a function out of it as
function [extracted] = arrayextraction(Data,indices)
lengthx = length(indices);
lengthy = height(Data);
extracted= NaN([lengthy lengthx]);
extracted= array2table(cumx);
for i = 1:lengthx
num = indices(i);
a = Data(1:num);
padding = lengthy-height(a);
extracted(:,i)= array2table(padarray(a,padding,NaN,'post'));
end
end
When I call the function using the following code, it gives an error of 'Not enough input arguments'. The only difference is something to do with the indices. When I put the indices vector inside the function, it works, but when I put it as input, it gives error. I call the function using the following code
Data= load('array.mat');
array = Data.array
b = arrayextraction(Data);
I ran through the help and documentation, it may be a simple misunderstanding that i cannot figure out and I will appreciate help in this regard.
Thanks
Good day.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Text Files finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!