MATLAB: How to extract values from a field of a stucture

strucure- handling fields

Hi everyone, I state that I'm a beginner in the use of Matlab, so I guess that what I'm asking could be solved quite easily, but I have been reading and trying a lot of different ways and still, I have no solutions. I have a structure ("Dati"), which is generated by an external software that works on a geographic grid. This grid has 196 cells in the X direction, and 337 in the Y direction; On this grid 244 different scenarios have been launched.
By writing "A=extractfield(Dati,'Val') I get, of course, the list of all the data inside the structure, and by "plot(extractfield(Dati,'X'),extractfield(Dati,'Y'))" I can represent the grid; but what I would like is to get the chance to represent in a plot the grid with all the different scenarios (244), and be able to handle the value of the third variable (energy per transport) in order to later calculate an average. Can someone help me?

Best Answer

I don't have the data so I cannot test it. Try
% select the Scenario
iScenario = 1;
% plot
surf(Dati.X,Dati.Y,Dati.Val(iScenario,:,:));
Note that the field Val has different dimensions from X and Y, so the previous code doesn't work. But maybe you have more insight on the original data