You should first initialize the variable y. I also changed the definition order of the elements of y. I didn't understand why you assigned the value of 0.49 to k at the end of the code?!
clc;
clear;
close all;
k=3:50
y = zeros(numel(k)); % initialize variable y with the same length as k
Best Answer