필터 지우기
필터 지우기

hey how can i make column output?

조회 수: 3 (최근 30일)
Ariela Glikman
Ariela Glikman 2018년 11월 26일
댓글: madhan ravi 2018년 11월 26일
hey how can i make column output? (and not row vec)
% the function gets a vector of numbers (=vecOfNum)
% and return output vector (=vecPrevMean),
% each element is the average of all previous elements.
function [vecPrevMean]= vecMean(vecOfNum)
count=1; %count the amount of elements in the vector
sumNum=0; %sum the elements
for i=1:length(vecOfNum);
if iscolumn(vecOfNum)==0
sumNum= sumNum+ vecOfNum(i);
vecPrevMean(i)=sumNum./count;
count=count+1;
elseif iscolumn(vecOfNum)==1
sumNum= sumNum+ vecOfNum(i);
vecPrevMean(i)=(sumNum./count)';
count=count+1;
end
end

채택된 답변

madhan ravi
madhan ravi 2018년 11월 26일
vecPrevMean(i,1)=(sumNum./count)';
% ^---------change to this (note : preallocation is also important)
  댓글 수: 1
madhan ravi
madhan ravi 2018년 11월 26일
It represents column vector learn more about vectors . If my answer worked make sure to accept the answer, also see the answer in your previous question.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by