Visualize data in a pivot-table like style

3 views (last 30 days)
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

Accepted Answer

Harald
Harald on 6 Feb 2024
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 Comment
Sebastian Stumpf
Sebastian Stumpf on 7 Feb 2024
Edited: Sebastian Stumpf on 7 Feb 2024
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

Sign in to comment.

More Answers (0)

Categories

Find more on Numeric Types in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!