hey how can i make column output?

3 次查看(过去 30 天)
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