이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to fill a table in AppDesigner with data from cell?
조회 수: 11 (최근 30일)
이전 댓글 표시
JoKi
2020년 7월 11일
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
madhan ravi
2020년 7월 11일
Kannst du uns zeigen, wie x1 aussieht? Bin kein Pro im AppDesigner, aber kann versuchen.
Adam Danz
2020년 7월 11일
According to your code, x is a char array. X1 must also be a char array. The image above shows a cell array containing a vector where 10:36:11 results in a scalar value of 10. Some something doesn't add up. I also don't understand how those values represent time-of-day.
JoKi
2020년 7월 11일
well the time there would be 10am 36min 11s, if that is what you mean.
If i run the code in the command window on its own i get this:

madhan ravi
2020년 7월 11일
편집: madhan ravi
2020년 7월 11일
Ersetze
cell2mat(x1)
durch
datenum(x1{:})
oder
duration(x1{:})
JoKi
2020년 7월 11일
Dann erhalte ich den Wert 7.3779e+05? Allerdings wird mir das zumindest in der Tabelle angezeigt
JoKi
2020년 7월 11일
Bekomme dann den Error: The following error occurred converting from duration to double:
Undefined function 'double' for input arguments of type 'duration'. To convert from durations to numeric, use the SECONDS, MINUTES, HOURS, DAYS, or YEARS functions.
madhan ravi
2020년 7월 11일
편집: madhan ravi
2020년 7월 11일
Kannst du den Inhalt von x1 anzeigen und welche Version von MATLAB verwendest du?
JoKi
2020년 7월 11일
achso, aber das x1 ist das gleiche welches ich hier am Anfang in den Kommentaren gepostet habe.
madhan ravi
2020년 7월 11일
편집: madhan ravi
2020년 7월 11일
Und jetzt, das gleiche?
x1 = regexp(x,'\d*','match');
X1 = num2cell(str2double(x1));
app.UITable.Data(i,2) = duration(X1{:})
Wenn es nicht funktioniert, du musst mindestens zwei CSV-Datei hochladen.
Adam Danz
2020년 7월 11일
편집: Adam Danz
2020년 7월 12일
After another quick look at your code, it looks like you could be reading the data in more efficiently, depending on how the csv files are organized.
Instead of using textscan perhaps you could use readtable or readcell or something similar. These functions allow you to read in datetime & duration values directly rather than reading them in as strings and converting them.
JoKi
2020년 7월 12일
@madhan ravi
für x1 und X1 bekomme ich jetzt für beide ein 1x3 cell
Zum testen lade ich immer 4 .csv Dateien hoch

@Adam Danz
my data looks like this:

JoKi
2020년 7월 12일
편집: JoKi
2020년 7월 12일
Nein leider nicht, ich bekomme die Fehlermeldung:
The following error occurred converting from duration to double:
Undefined function 'double' for input arguments of type 'duration'. To convert from durations to numeric, use the SECONDS, MINUTES, HOURS, DAYS, or YEARS functions.
Ich habe den Code jetzt so eingegeben:
x = char(Daten(i).Header(12,1));
x1 = regexp(x,'\d*','match');
X1 = num2cell(str2double(x1));
app.UITable.Data(i,2) = duration(X1{:});
madhan ravi
2020년 7월 12일
Welche Version von MATLAB verwendest du? Mit 2020a bekomme ich keinen Fehler. Beachte, dass die Duration im Jahr 2014 eingeführt wurde.
JoKi
2020년 7월 12일
Ohh entschuldige, das habe ich überlesen. Ich benutze auch MATLAB R2020a. Dann muss ich irgendwo einen Fehler beim eingeben gemacht haben oder?
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.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)