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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Berat Can Karatas
Berat Can Karatas il 22 Lug 2020
Modificato: Berat Can Karatas il 22 Lug 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)))

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by