Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Assign each column seperately to each customer.

조회 수: 1 (최근 30일)
awda
awda 2014년 4월 10일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (1개)

Jos (10584)
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
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.
awda
awda 2014년 4월 10일
unfortunately it is wrong. i want it to show me a graph of all the 64 customers. but 1 graph for each. so i want a for loop using kth customer. where i can call it later to plot with..
right now using jos's code i get wrong data.
since 1 customer have 24x63 matrix.. mean of the 24 hours row will be: 24x1 matrix. and that is good.. if it was possible to make it do that with all of the customer and have a resulting matrix of 24x64.. it would be great.. however with jos code i get wrong mean values even after puting the k instead of the 1 and puting it inside his loop.
any ideas :)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by