How to Evaluate Value In Array in Cell Mode

1 view (last 30 days)
Mel
Mel on 18 Apr 2012
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

Answers (1)

Sean de Wolski
Sean de Wolski on 18 Apr 2012
Put a break point on that line and inspect the variables.

Tags

Community Treasure Hunt

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

Start Hunting!