How to pick the values from individual grids ?

Hi everyone,
May someone help me here ,,
My data set is consists of three paramateres ... x, y and z ..
the x, y paramteres are grided at an interval of 0.005, This give me a matrix of 16 by 16 grid ..
In each grid z-values are placed. Now I want to calculate the the z vales in each grid ...
The figure show the pictorial representation of data in each grid ... My task is to generate an output file with 256 columns and each colum give us the values of point placed in each grid ..
Thank you
clear all
%clc
a=xlsread('data');
x=a(:,1);% x parameter
y=a(:,2); %y parameter
z=a(:,3); % z parameter
%Grid scale
x2=-130.04:0.005:-129.96;
y2=45.91:0.005:45.99;

8 comentarios

KSSV
KSSV el 25 de Sept. de 2020
How different is your question from the previous asked question?
aa
aa el 25 de Sept. de 2020
In previous time I just want to plot data in grids ... But now I want to pick the values palced in each grid ...
KSSV
KSSV el 25 de Sept. de 2020
Dear friend....the old question's answer already shows you how to pick the data. You can plot the data only after picking the points.
aa
aa el 25 de Sept. de 2020
I am agree with you ... I have attempted multiple time to extract the data in each grid but still unsuccessful. May you help me here ...
You can store the data in a cell array, so from the previous question that would just be
zStore{i,j} = z(idx); % place in the inner loop after idx is determined.
assuming you want to store z values only.
aa
aa el 25 de Sept. de 2020
great ... this works ... but its a grid of 16 by 16 .. if I want to check data in each grid point i have to click each grid one by one ... is it possible to get an output in excel sheet in 256 colums
Walter Roberson
Walter Roberson el 25 de Sept. de 2020
The different columns would have to have different lengths. How would you like that to be dealt with?
aa
aa el 25 de Sept. de 2020
Yes ,,, with a Nan for empity cells.

Iniciar sesión para comentar.

 Respuesta aceptada

Turlough Hughes
Turlough Hughes el 25 de Sept. de 2020
Editada: Turlough Hughes el 29 de Sept. de 2020
The objective is to create an excel sheet with columns of data having different length. You can store data that has different lengths in a cell array as mentioned in the comments by inserting following line into the answer provided by KSSV after idx has been determined in the inner loop:
zStore{1,j+(n-1)*(i-1)} = z(idx); % inside the loop
To demo the problem one can alternatively generate an example of zStore with the following:
for c = 1:256
N = randi([50 200],1);
zStore{1,c} = rand(N,1);
end
Convert zStore to a matrix padded with NaNs so that all columns have the same length as the longest column vector in zStore:
N = max(cellfun(@numel,zStore));
zMat = nan(N,256);
for i = 1:numel(zStore)
zMat(1:numel(zStore{1,i}),i) = zStore{1,i};
end
Then you can write the matrix out to an excel sheet
writematrix(zMat,'data.xlsx')

2 comentarios

aa
aa el 29 de Sept. de 2020
Hi,
I have attempted with the code you have provide dbut still did not get the expected output ...
May you help me here
Turlough Hughes
Turlough Hughes el 29 de Sept. de 2020
I've edited the line that goes inside the loop to store z values. Let me know if that works for you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

aa
el 25 de Sept. de 2020

Comentada:

el 29 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by