Info
This question is closed. Reopen it to edit or answer.
Matrix Manipulation and Storage Help!
3 views (last 30 days)
Show older comments
For the code below, I am having problems with matrix manipulation and keep getting dimensional mismatch errors. In this loop, I want the results of noiseData(ii,jj) to be subtracted from every value in the corresponding Tdat file (each variation is stored as a 721600x1 column vector), then placed into a new matrix, side by side. The dimensions of this matrix should be 721600x8 (for 8 iterations in the loop). Help please! Note: I tried using only storing Tdat from 1:1000 in this code, because I thought that maybe the data files had different lengths, but that seems to not be the case.
%%Load Data
for ii = 1:2
% We loop through the passive and active grid data. Because it is saved
% in a cell format, we must use the char() command.
test = char(tst(ii));
for jj = 1:4
% Noise Data
filnme = ['zero_' num2str(jj) '_' test '_fix']; % Define file name
load([mfol Nodat '/' filnme '.txt']) % Load data
% Save the data (second column)
eval(['Zdat = ' filnme '(:,2);'])
% Convert for force
Zdat = polyval(Vfit,abs(Zdat));
% Save the mean zero data for use down the road
noiseData(ii,jj) = mean(Zdat);
eval(['clear ' filnme]); % Clear old variable to save space
% Thrust Data
filnme = [num2str(jj) '_' test]; % Define file name
load([mfol Thrdat '/' filnme '.txt']) % Load data
% Save the data (second column)
eval(['Tdat = X' filnme '(:,2);'])
% Convert for force
Tdat = polyval(Vfit,abs(Tdat));
% Save mean thrust data
MeanThrust(ii,jj) = mean(Tdat);
eval(['clear X' filnme]); % Clear old variable to save space
% Remove noise from thrust data
if ii == 1
ThrustActual(jj) = Tdat(1:1000) - noiseData(ii,jj);
elseif ii == 2
ThrustActual(jj+4) = Tdat(1:1000) - noiseData(ii,jj);
end
end % jj
end % ii
0 Comments
Answers (1)
Walter Roberson
on 13 Jun 2017
Shrug. You are magically creating variables in the middle of execution by using load(). MATLAB is permitted to overwrite your variables in strange ways when you do that. It isn't worth debugging.
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!