MATLAB: How make code has 2 vectors as input and make loop than find output as vector

homeworkloopvector

Hi everyone.
I need know how I can make code I can put two vectors and use them in loop to find another vector as output.
So, for make clear. I have two vectors one of them is time (s), and another one is v ( ft/s ). I want make loop to find acceleration = (V1-V0)/(t1-t0).
Thank you

Best Answer

  • v=rand(10,1);
    t=[0:0.1:0.9]';
    a=zeros(numel(v),1);
    for ii=2:numel(v)
    a(ii,1)=(v(ii)-v(ii-1))/(t(ii)-t(ii-1));
    end
    disp('Acceleration:')
    a