필터 지우기
필터 지우기

Visualize data in a pivot-table like style

조회 수: 4 (최근 30일)
Sebastian Stumpf
Sebastian Stumpf 2024년 2월 6일
편집: Sebastian Stumpf 2024년 2월 7일
Dear all,
I tried a lot, even the new Pivot function in Matlab 2023a, but I can not achieve what I am looking for.
I have this kind of data containing x, y and z values (See attached file "Testvalues.mat"). Sometimes there are more datapoints, sometimes less. And I want to have a chart looking like this (made in Excel for demonstration):
It is some kind of Pivottable, but I have diffiulties to achieve a visualization like this. The order is from -4500 to 12000 and 1500 to 10500 important.
Is there a way to get this output as a table with a Matlab function or code?
Thanks a lot and kind regards,
Sebastian

채택된 답변

Harald
Harald 2024년 2월 6일
Hi,
unstack and a few modifications should do the job:
load TestValues.mat
T = array2table(dataset8_max_langs);
T.dataset8_max_langs1 = cell2mat(T.dataset8_max_langs1);
T.dataset8_max_langs2 = cell2mat(T.dataset8_max_langs2);
T.dataset8_max_langs3 = string(T.dataset8_max_langs3);
T2 = unstack(T, "dataset8_max_langs3", "dataset8_max_langs1", ...
"VariableNamingRule","preserve");
T2 = fillmissing(T2, "constant", "", "DataVariables",@isstring);
T2 = sortrows(T2, "dataset8_max_langs2", "descend");
It seems like the data you have provided is not the same as the data you used for the chart. That makes it difficult to compare. Thus, please let me know if this is not the format you have been looking for. For example, you may want to use dataset8_max_langs2 instead of dataset8_max_langs1 in the unstack command.
Best wishes,
Harald
  댓글 수: 1
Sebastian Stumpf
Sebastian Stumpf 2024년 2월 7일
편집: Sebastian Stumpf 2024년 2월 7일
Hi,
thank you very much for the quick and competent help. This is it! I was on the right way, but this is very helpful. The only thing that's missing is, that the data contains integer numbers and non-integer numbers. I just need the integer numbers in the finished table. But I can figure this out by myself.
Sorry for not providing the same data as the data I used for the chart.
Nevertheless, thank you very much!
Kind regards,
Sebastian

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by