I want to convert a single column of data from a .txt file as shown then operate on it by the script shown but I get error "left is 1x1 right is 1x243003"
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Duane Melvin
am 7 Jun. 2022
Beantwortet: Kevin Holly
am 7 Jun. 2022
here is the .txt file except it has no space rows (this editor put those spaces geeze)
I want to keep the right I.E. 0.047817 but throw away the left column 0.666700 scroll down for rest of questiuon
0.666700 0.047817
0.676700 0.047628
0.686700 0.047439
0.696700 0.045927
0.706700 0.044415
0.716700 0.045171
0.726700 0.046116
0.736700 0.045549
0.746700 0.045171
0.756700 0.044226
0.766700 0.043470
0.776700 0.045738
0.786700 0.047439
0.796700 0.047817
0.806700 0.048762
0.816700 0.048762
0.826700 0.047628
0.836700 0.044604
0.846700 0.043659
0.856700 0.044982
0.866700 0.044226
0.876700 0.043281
0.886700 0.043848
0.896700 0.045171
0.906700 0.045738
0.916700 0.046305
0.926700 0.047250
0.936700 0.047061
0.946700 0.044415
0.956700 0.041769
here is my script which is functional in another instance where the file is retrieved by using ----- fileID=fopen('filename.txt', 'r'); this is because the 'filename.txt' file already has the left column removed.
I was trying to use import data on the above .txt file then remove the first column with data(:,2) then push into omega for the script go to bottom to see the error I get when run
Fs = 100;
t0 = 1/Fs;
data = importdata('1st stab prime1.txt');
data(:,2)
omega = data;
%disp(omega)
%omega = fscanf(fileID,formatSpec) % determine omega
%fclose(fileID);
theta = cumsum(omega, 1)*t0; %determine theta
%disp(omega);
%disp(theta);
maxNumM = 100;
L = size(theta, 1);
maxM = 2.^floor(log2(L/2));
m = logspace(log10(1), log10(maxM), maxNumM).';
m = ceil(m); % m must be an integer.
m = unique(m); % Remove duplicates.
disp(m);
tau = m*t0;
avar = zeros(numel(m), 1);
for i = 1:numel(m)
mi = m(i);
avar(i,:) = sum( ...
(theta(1+2*mi:L) - 2*theta(1+mi:L-mi) + theta(1:L-2*mi)).^2, 1);
end
avar = avar ./ (2*tau.^2 .* (L - 2*m));
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-243003.
Error in Allan_Dev_ACC_GS520_6_7_2021 (line 50)
avar(i,:) = sum( ...
0 Kommentare
Akzeptierte Antwort
Kevin Holly
am 7 Jun. 2022
I imported the data with the function attached and did not recieve an error.
Fs = 100;
t0 = 1/Fs;
omega = importdata('testing.txt');
%omega = fscanf(fileID,formatSpec) % determine omega
%fclose(fileID);
theta = cumsum(omega, 1)*t0; %determine theta
disp(omega);
disp(theta);
maxNumM = 100;
L = size(theta, 1);
maxM = 2.^floor(log2(L/2));
m = logspace(log10(1), log10(maxM), maxNumM).';
m = ceil(m); % m must be an integer.
m = unique(m); % Remove duplicates.
disp(m);
tau = m*t0;
avar = zeros(numel(m), 1);
for i = 1:numel(m)
mi = m(i);
avar(i,:) = sum( ...
(theta(1+2*mi:L) - 2*theta(1+mi:L-mi) + theta(1:L-2*mi)).^2, 1);
end
avar = avar ./ (2*tau.^2 .* (L - 2*m))
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numeric Types finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!