How to add up multiple values at every co-ordinate.

1 vue (au cours des 30 derniers jours)
Alexandra Ridgway
Alexandra Ridgway le 23 Fév 2017
Modifié(e) : John BG le 1 Mar 2017
Hi,
I have a data (LIG6) set which has values for iron (Fer) at multiple depths, for multiple co-ordinates across the globe. I can plot
contourf(LIG6.Fer(:,:,1)');
However I do not want just the Fer at the surface (1), I want the sum of Fer at every depth at each lat/long, and then be able to plot those values over the globe.
Any ideas?
Alex

Réponses (2)

John BG
John BG le 25 Fév 2017
Alexandra
understanding that
contourf(LIG6.Fer(:,:,1)');
is a matrix 3x3xN where N is constant or varies from Lat Long point
if N is constant, you have all depths over all points, even if only filled with 0 or NaN then
[sz1 sz2 sz3]=size(LIG6.Fer) % measure size array
X=LIG6.Fer(:,1) % extract latitudes
Y=LIG6.Fer(:,2) % extract longitudes
contourf(X,Y,sum(LIG6.Fer(:,:,[1:end])'));
if N is not a constant, meaning the amount of Fe measurements vary between [Lat Long] then you have to extract first each depth and apply it to where I wrote 'end'
I would you to have my answer as accepted so please let me know whether the constant N assumption is correct or you want to proceed extracting each individual and varying depths.
Appreciating time and attention, awaiting answer
John BG
  5 commentaires
John BG
John BG le 25 Fév 2017
Alexandra
ok, implementing the extraction of varying amounts of depths is easy with cells,
but to avoid guess work, would it be possible for you to provide a sample,
just a few points of countourFe68, points that have different amounts of depths, ok?
please attach it to your question
awaiting answer
Alexandra Ridgway
Alexandra Ridgway le 26 Fév 2017
Modifié(e) : Alexandra Ridgway le 26 Fév 2017
Hi, I have rerun it and bob is 2D (360x180) my plot just looks very odd (see picture), and I've no idea why! Thank you for trying to help me:)
For context it should look like the second image (note the axis)..

Connectez-vous pour commenter.


John BG
John BG le 1 Mar 2017
Modifié(e) : John BG le 1 Mar 2017
thanks for attaching the images showing what you get so far and what you expect.
Are you reading with MATLAB from XML format data, from for instance a GOCAD export?
or do you already have a MATLAB structure in the workspace?
anyway, it would greatly help to know the specifics of the structure LIG6.
can you attach a sample? if you already have a MATLAB variable for the LIG6 structure, save LIG6 to a .mat file
save sample1.mat LIG6
or
save('sample.mat','LIG6')
if the name of the structure or sample structure is not exactly LIG6 please use the name of the variable accordingly
and attach the .mat file to your question or comment
John BG

Community Treasure Hunt

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

Start Hunting!

Translated by