MATLAB: Generate y(n)=y(n-1)+x(n) recursive hello i want to generate y(n)=y(n-1)+x(n). by using a for loop I can find the last value of y, but i need to store all values of y from n =1 till n. Who do I do that? Best Answer n=10y0=0; % Initial conditions y(1)=y0+x(1); for k=2:n y(k)=y(k-1)+x(k)end Related SolutionsMATLAB: How to write y(n)=y(n-1)+x(n) in a way to store all values of y from n=1 to n There are vectorized ways to do this, but using your formula directly:y = zeros(size(x));y(1) = something; % <-- you fill this in, e.g. maybe x(1)?n = something; % <-- you fill this infor k=2:n % <-- for the rest of the elements through n y(k) = y(k-1) + x(k); % <-- your formulaend MATLAB: I get “In an assignment A(:) = B, the number of elements in A and B must be the same.” error when I execute the following code. Do you need to index the sin(y) as as sin(y(n)) in this line:x(n+1)=(log(x(n)^2)-sin(y(n))+(3*x(n)/2)); Related QuestionI WANT TO FIND CORRELATION OF X[N] WITH X[N],X[N] WITH Y[N] AND Y[N] WITH Y[N].Finding Values From Arrays
Best Answer