Info
此问题已关闭。 请重新打开它进行编辑或回答。
Assign each column seperately to each customer.
2 次查看(过去 30 天)
显示 更早的评论
Dear fellow matlab users
I have stomped upon a problem involving seperating / assigning customers to a column of data. for more explanation read after watching this picture:

i have a set of data looking this ^ .. each column represents 1 customer. so column 1 ==> customer 1. etc.. what i want is make a code that assigns each of the columns to 1 customer in a new array. cause i will divide the 1 column data into 24 (24 hours).. and then plot it.
is it possible to do it using For or while loops..instead of doing it manualy since there is 64 customers.
Regards
a curious matlab user
0 个评论
回答(1 个)
Jos (10584)
2014-4-10
Why do you want to separate the columns? To access data of a specific customer, just use indexing into your matrix. This will keep your code very clean. You can retrieve the data of each customer
for k=1:size(OriginalMatrix,2)
CustomerData = OriginalMatrix(:,k) ;
% process, for instance, take the mean:
MeanValue(k) = mean(CustomerData) ;
end
but often you can take advantage of ML capability to operate on multiple columns at once! The code above can be replace by the statement:
MeanValue mean(OriginalMatrix,1) ;
4 个评论
Image Analyst
2014-4-10
Looks pretty much like Jos's code. Just put it inside a loop over k, and replace your 1 with k to get the kth customer instead of the first customer.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!