MATLAB: “Inputs must be scalars” error message whilst using linspace command

linspace

Im trying to use the linspace command (in the form of x1,x2,n)on the second column of a previously created array, so that it creates vectors from the highest value to the lowest value but I keep getting an error message saying "inputs must be scalars". Here is the section of my code:
A=table2array(Data);
SSD = A(:,3)-SimulatedY.^2;
SSD = sum(SSD);
Xplot(icount,jcount,kcount) = i;
Yplot(icount,jcount,kcount) = j;
Tplot(icount,jcount,kcount) = k;
Zplot(icount,jcount, kcount) = SSD;
if SSD < MinimumSSD
MinimumSSD = SSD;
Bestparams1 = i;
Bestparams2 = j;
Bestparams3 = k;
end
end
end
end
figure
hold on
plot(A(:,1),A(:,3),'o') %plot actual data
a =linspace(min(A(:,2)):max(A(:,2)),30);

Best Answer

your last line of code should be
a =linspace(min(A(:,2)), max(A(:,2)),30);
you had a colon separating min(A(:,2)) and max(A(:,2)) you need a comma
Related Question