Getting an error on reading a file
1 view (last 30 days)
Show older comments
I am using the current matlab script in which the file imu_data.bin is already existing
filename = 'imu_data.bin';
[inertial_data,time_stamps,raw_data]=parse_imu_data(filename);
%delete(filename);
i=0;
while i >=0
filename1 = 'inertial_data.bin' ;
file1 = fopen(filename1, 'w');
fwrite(file1,fread(inertial_data,'uint8'),'uint8');
i = i+1;
fclose(file1);
end
% Plot data in SI units
figure(1),clf, hold on
plot(inertial_data(1:3,:)');
plot(sqrt(sum(inertial_data(1:3,:).^2)),'c');
grid on
title('Accelerometer readings');
xlabel('sample number')
ylabel('a [m/s^2]');
figure(2), clf, hold on
plot(inertial_data(4:6,:)'*180/pi);
plot(sqrt(sum((inertial_data(4:6,:)*180/pi).^2)),'c');
grid on
title('Gyroscope readings');
xlabel('sample number')
ylabel('\omega [deg/s]');
figure(3),clf, hold on
subplot(2,1,1);
plot(double(time_stamps)'/64e6,'b-');
grid on
title('Time stamps');
xlabel('sample number')
ylabel('[s]');
subplot(2,1,2);
dt = diff(double(time_stamps)');
for i=1:numel(dt)
if dt(i)<0
dt(i) = dt(i)+2^32;
end
end
plot(dt/64e6,'b-');
grid on
title('Time differentials');
xlabel('sample number')
ylabel('[s]');
figure(4), clf, hold on
plot(sqrt(sum((inertial_data(4:6,:)*180/pi).^2)),'c');
grid on
Iam getting the following error message
"Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in line
fwrite(file1,fread(inertial_data,'uint8'),'uint8');"
0 Comments
Answers (1)
Walter Roberson
on 23 Nov 2015
Opening inertial_data.bin for writing failed. You should check to see which directory you are cd()'d to, as you might be in a directory that you do not have permission to write in.
2 Comments
Walter Roberson
on 23 Nov 2015
Edited: Walter Roberson
on 23 Nov 2015
Please show the result of
exist('inertial_data.bin')
dir('inertial_data.bin')
fileattrib('inertial_data.bin')
fileattrib('.')
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!