How to store multiple vectors in an array?
Show older comments
Hey there,
i have a problem to store my vectors (force measurement signals), that have all different length, in an array using a for loop.
I am using Matlab App Designer and y/x are properties. The Error i get is: Unable to perform assignment because the size of the left side is 1-by-5319 and the size of the right side is 8545-by-1. So what i understand is that the first iteration performs succesfully, but what i dont understand why the stored data is 1x5319 (column), because the data im filtering is 5319x1(row) (this is for example the first data im reading in). I know there is a lot of information about storing data, but im kinda new to matlab and im getting a bit confused here. So thanks for any help!
for i = 1:length(filename)
filepath=fullfile(pathname, filename);
fid = fopen (filepath{i});
%[file,path]=uigetfile('*.csv');
A = textscan(fid, '%s%s%s%s%s%s%s%s%s%s%s%s%s','Delimiter',';');
%Umwandeln von Cell --> String
B=string([A{:}]);
%',' durch '.' ersetzen
B=replace(B,',', '.'); % ',' durch '.' ersetzen
% Aufteilen in Header und Messdaten
Daten(i).Header=B(1:30,:);
Daten(i).Messdaten=str2double(B(31:end,7));
end
for i = 1:length(filename)
%Uhrzeit / time
u= char(Daten(i).Header(12,1));
u1 = extractBetween(u,13,20 );
%Datum / date
d = char(Daten(i).Header(11,1));
d1 = extractBetween(d,11,20);
%Bein Seite / leg
be = char(Daten(i).Header(21,1));
if strlength(be) == 22
be1 = extractBetween(be,10,14);
else
be1 = extractBetween(be,10,15);
end
% Bewegung /
b = char(Daten(i).Header(23,1));
if strlength(b) == 32
b1 = extractBetween(b,13,21);
else
b1 = extractBetween(b,13,19);
end
% Kraft Tiefpass Filter / lowpass filter
app.x = Daten(i).Messdaten;
windowsize = 5;
c = (1/windowsize)*ones(1,windowsize);
a = 1;
app.y(i,:) = filter(c,a,app.x); % This line is causing the Error
M =max(app.y);
% Einlesen der Daten in Tabelle
data(i,:) = [d1 u1 b1 be1 M];
end
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!