Store data into an Array or variable
조회 수: 16 (최근 30일)
이전 댓글 표시
BELOW is a part of my codes. ARDUNIO - MATLAB.
PROBLEM: I want to store all values of P, Q and V in every update of the loop so that it would now be easy for me to print it to excel using xlswrite.
CAN SOMEONE HELP ME WITH THIS. Or any alternative to store the data for DATA ACQUISITION FOR MY STUDY. your answers are a great help.
while strcmp(start,'DISCONNECT')
RxText = fscanf(serConn);
RxText = strtrim(RxText);
disp(RxText);
pause(0.5)
%%%%%%%for data acquisition
handles.counter = handles.counter + 1;
[InRange,power,va,var,pf,volt,current,id]=strread(RxText,'%s%s%s%s%s%s%s%s','delimiter',',');
%%%MAIN POWER ANALYZER
if strcmp(id,'B') %DATA FOR MAIN PA
set(handles.LP4,'String',power);
set(handles.LQ4,'String',var);
set(handles.LV4,'String',volt);
%%%%CONVERT STRING TO DOUBLE %%%%%%
P4= str2double(power);
Q4 = str2double(var);
V4 = str2double(volt);
%%%%CONDITION SET TO LOAD MAIN STAT
if P4>70 && P4<80
set(handles.STAT4,'String','WARNING');
elseif P4>80
set(handles.STAT4,'string','SYSTEM OVERLOAD');
else
set(handles.STAT4,'string','NORMAL');
end
%%%%%DATA ACQUISITION %%%%%
P4(handles.counter,1) = P4
%Q4(handles.counter,2) = Q4;
%V4(handles.counter,3) = V4;
% data = [P1 Q1 V1]
end
댓글 수: 0
채택된 답변
Walter Roberson
2013년 3월 5일
count = 0; %before loop
Inside the loop,
count = count + 1;
data(count, :) = [P1 Q1 V1];
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!