필터 지우기
필터 지우기

How to Evaluate Value In Array in Cell Mode

조회 수: 2 (최근 30일)
Mel
Mel 2012년 4월 18일
I want to perform a simple subtraction operation on the value in a cell array that I imported from a text file. See below code. My problem is when I evaluate the value of 'total_time', it spits out some strange array when it should simply be a value. Please help.
%READS FILE AND SAVES DATA INTO MATRIX
filename='data.txt';
[A,B,C]=textread(filename, '%s %s %s');
number_rows=size(A,1);
matrix=cell(number_rows, 3);
matrix(:,:)=[A, B, C];
sampling_rate_current= 10000;
sampling_rate_new=1000;
factor=sampling_rate_current/sampling_rate_new;
% LET X=0 IF EVENLY DIVISIBLE
% LET X=1 IF NOT EVENLY DIVISIBLE
%x=0;
x=1;
%DOWNSIZE DATA IF EVENLY DIVISIBLE
i=1;
j=1;
if x==0
while i<number_rows
matrix_down(j,:)=matrix(i,:);
j=j+1;
i=i+factor;
end
end
%DOWNSIZE DATA IF NOT EVENLY DIVISIBLE
if x==1
%generate times to be extarcted
start_time=matrix(1,1);
end_time=matrix(number_rows,1);
total_time=end_time{1,1}-start_time{1,1};
interval=1/sampling_rate_new;
i=1;
j=0;
total=total_time/sampling_rate_new;
while i<=total
time_points(i,1)= start_time+j*interval;
j=j+1;
end
end

답변 (1개)

Sean de Wolski
Sean de Wolski 2012년 4월 18일
Put a break point on that line and inspect the variables.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by