To obtain the average 'B' value by using Theta value according to each R value in the 3960x4 Matrix

1 visualización (últimos 30 días)
Dear colleagues,
I am trying to calculate a B value. I have a 3960x4 matrix. In this matrix, R value is the first column, Theta value is the second column and Bz value is the fourth column. (No need for the third column.)
My purpose is to find the average of the B values in all Theta values for each R value. I will draw the graph (43x2) of B according to the R values.
Example:
For R=2,
B(Theta_0(R=2)) + B(Theta_1(R=2)) + B(Theta_2(R=2)) + ... + B(Theta_89(R=2))= Avg(B(R=2))
Many thanks

Respuesta aceptada

Berat Can Karatas
Berat Can Karatas el 22 de Jul. de 2020
Editada: Berat Can Karatas el 22 de Jul. de 2020
I found solution by myself.
Here is the code without loop.
X=readtable('rt_v1.txt');
R(:,1)=X{:,1}/100;%radius (m)
R(:,2)=X{:,4}*0.0001; %magnetic field (Tesla)
A=sortrows(R,1); %sorting according to R value
[r,c] = size(A);
nlay = 42; % layer size
Avg = transpose(squeeze(mean(permute(reshape(A',[c,r/nlay,nlay]),[2,1,3]),1)))

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by