[Solved] how to calculate comedian(c) in matlab? [closed]


Quick answer (because you finally explained a workable example input=>desired output) before closing the question.

x = [1 2 3 ; 4 5 6 ; 7 8 9] ;
T = size(x,1) ; N = size(x,2) ;

R = [x,x(:,1)] ;                % copy the first column in last position (to be able to loop seamlessly)
for k=1:N
    R(:,k) = R(:,k).*R(:,k+1) ; % multiply columns element wise
end
R(:,end) = []                   % remove the last column

R =
     2     6     3
    20    30    24
    56    72    63

I suggest you read about indexing in MATLAB on Mathworks site

solved how to calculate comedian(c) in matlab? [closed]