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

1 回表示 (過去 30 日間)
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

採用された回答

Berat Can Karatas
Berat Can Karatas 2020 年 7 月 22 日
編集済み: Berat Can Karatas 2020 年 7 月 22 日
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)))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by