MATLAB Answers

Index in position 2 exceeds array bounds

3 views (last 30 days)
Brian Wright
Brian Wright on 27 Oct 2020
Answered: Walter Roberson on 27 Oct 2020
Hello everyone,
I'm attempting to load a sample transmitted using my BladeRF software defined radio into Matlab. I am using a function title load_csv.m that obtained from this url: https://github.com/Nuand/bladeRF/commit/2c4c839fa7db0a69c9c8386476bfb3a65d246679
The function looks like this:
function [signal, signal_i, signal_q] = load_csv(filename)
csv = load(filename);
signal_i = csv(:,1)./2048.0;
signal_q = csv(:,2)./2048.0;
signal = signal_i + 1j .* signal_q;
end
Below is the syntax I use to load the file onto Matlab
rxSignal = load_csv('tmp_samples_rx.csv');
When I attempt to load the file using the function, I receive this error:
Index in position 2 exceeds array bounds.
Error in load_csv (line 3)
signal_i = csv(:,1)./2048.0;
Error in wright2 (line 32)
rxSignal = load_csv('tmp_samples_rx.csv');
The file I wish to load is a 60000x1 complex double column vector. Below is a snippet of how it appears in excel:
4027.93116292808 - 3784.63252459062i
2816.19836118964 + 3765.05233953550i
-1521.08335162319 + 1152.10900371074i
788.234574060302 - 344.859698124550i
2809.99684023969 - 17.7521355649638i
3349.50894392745 - 3971.60199301312i
2397.26710342550 - 828.867857375982i
-2624.74960536111 + 1626.75805561092i
2124.63229460262 - 2523.10793458054i
-2056.09513835153 + 6021.24174720362i
2533.24506339406 + 388.808184162790i
-1076.78779180958 - 2404.97342447914i
-1457.61704657447 + 1359.60948568635i
-1363.24345612490 + 1872.82516921698i
18.1981623649926 + 2612.84929535454i
3254.97080667371 + 3951.45426258370i
-877.535021284633 - 1670.26243972526i
1216.34789611091 - 805.351743676328i
-1968.04412147153 + 5724.45384652862i
-8.31725915849152 + 451.354464010482i
Does anyone know what I can do to resolve this issue?
Any help received is much appreciated.
V/r,
Brian W

  0 Comments

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 27 Oct 2020
4027.93116292808 - 3784.63252459062i
That is not two columns: that is a single column that is complex-valued.
signal = csv ./ 2048; %no need for the other steps

  0 Comments

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by