How to fill a table in AppDesigner with data from cell?

조회 수: 11 (최근 30일)
JoKi
JoKi 2020년 7월 11일
댓글: JoKi 2020년 7월 14일
Hello,
i need some help since i dont really know how to solve my errors. My Datas is stored and i want it to be shown in a table but the error im getting is: "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side."
So my Data i want to show is date, time, left or right side and name.
Thanks for any help!
% Button pushed function: EinlesenButton
function EinlesenButtonPushed(app, event)
%Diese Funktion dient dem direkten Lesen der auf dem übergeben Pfad
%hinterlegten CSV-Datei. Diese Datei muss exakt der Formatierung der
%Dateien entsprechen die das Program "Power" des Diagnostikgerätes
%liefert.
%Einlesen der Datei über den Umweg mit strings
% Öffnen eines Fensters zur Auswahl der zu öffnenden .csv Dateien.
[filename,pathname] = uigetfile('*.csv;','MultiSelect',"on");
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
x = char(Daten(i).Header(12,1));
x1 = extractBetween(x,13,20 );
%Datum
y = char(Daten(i).Header(11,1));
y1 = extractBetween(y,11,20);
%Bein Seite
z = char(Daten(i).Header(21,1));
if strlength(z) == 22
z1 = extractBetween(z,10,14);
else
z1 = extractBetween(z,10,15);
end
app.UITable.Data(i,2) = cell2mat(x1); % <------ Here starts my problem
app.UITable.Data(i,3) = cell2mat(y1);
app.UITable.Data(i,4) = cell2mat(z1);
end
  댓글 수: 24
Adam Danz
Adam Danz 2020년 7월 12일
Based on those data, I'd use readtable. That function allows you to define the row where the tabular data start and it also allows you to define the input format of datetime values With 1 line of code you could read in the data with the correct datetime values.
JoKi
JoKi 2020년 7월 14일
Okay, i will try that. Thank you!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by