Below I have a function that returns a struct ( my actual code has many functions as methods in an object that return similar data).
function out = get_results1 mystruct.name = "result1"; mystruct.value = 23; mystruct.unit = 'mph'; out = mystruct;end
However I have some functions that return more than one result.. for example:
function out = get_results2 mystruct.name = {"result1"; "result2"}; mystruct.value = {23; 34 }; mystruct.unit = 'mph'; out = mystruct;end
My goal is to comebine the results of all of these functions into a table like the following:
a = get_results1();b = get_results2();combined = [a, b];mytable = struct2table(combined);
however this will not work because of inconsistent sizes… Could someone tell me the following:
1) Should I restructure my functions to provide a different output?
2) Is there another way pull out the nested structures from the functions that have multiple results?
Best Answer