I'm trying to write a script using MATLAB
that reads from a txt
file (which has 100*3
elements written in a single column). I want to read them 100
elements at a time and apply a fit exponential function. This is what I wrote:
defaultPath = 'my/default/path/';
prompt = 'file name? ';
fileName = input(prompt,'s');
fullPath = strcat(defaultPath,fileName);
fileID = fopen(fullPath);
for h = 1:3
buff = textscan(fileID, '%d', 100);
y=buff';
x = zeros([100, 1]);
for j = 1:100
x(j,1) = j;
end
f = fit(x,y,'exp1');
plot(f,x,y);
end
but it gives me this error :
X and Y must have the same number of rows.