Visualize data in a pivot-table like style

4 次查看(过去 30 天)
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