How to plot .bin file?

46 views (last 30 days)
Rizwan
Rizwan on 16 May 2023
Answered: Diwakar Diwakar on 22 May 2023
I make some binary file .bin files by connectiong an active GPS antenna to USRP 2900, now can any one help me how to plot those files using MATLAB to check that satellites are acquired or not on a given gain?
  12 Comments
dpb
dpb on 18 May 2023
stem(locs, 'r', 'LineWidth', 2);
should be
stem(locs,peaks, 'r', 'LineWidth', 2);
Walter Roberson
Walter Roberson on 18 May 2023
@dpb is right, the peaks are needed as well.

Sign in to comment.

Answers (1)

Diwakar Diwakar
Diwakar Diwakar on 22 May 2023
I can help you with plotting the data from your .bin files using MATLAB. To get started, you'll need to read the binary file and extract the relevant data. Since you haven't provided the specific format of your .bin files, I'll assume that the data is stored as a series of numerical values representing satellite acquisition information.
Here's an example MATLAB code that demonstrates how you can read the binary file, extract the data, and plot it:
% Specify the path to your .bin file
file_path = 'path/to/your/file.bin';
% Open the binary file for reading
file_id = fopen(file_path, 'rb');
% Read the binary data into a numerical array
data = fread(file_id, 'double');
% Close the file
fclose(file_id);
% Specify the gain threshold for satellite acquisition
gain_threshold = 10; % Adjust this value as needed
% Plot the data
figure;
plot(data, 'b');
hold on;
plot(find(data >= gain_threshold), data(data >= gain_threshold), 'ro');
hold off;
% Set plot labels and title
xlabel('Sample Index');
ylabel('Gain');
title('Satellite Acquisition');
% Display a legend
legend('Gain', 'Acquired Satellites');
% Adjust plot settings if needed
grid on;
Make sure to replace 'path/to/your/file.bin' with the actual file path of your .bin file. Also, adjust the gain_threshold value according to the gain level at which you consider a satellite to be acquired.
This code reads the binary file using fread, stores the data in the data array, and then plots the entire data as a blue line. It also marks the points where the gain exceeds the specified threshold with red circles.
Feel free to customize the code further based on your specific requirements or the structure of your binary file.

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!