Converting cylindircal data into regular cartesian grid

I have 4 csv files as follows
FieldMap_Bz.csv is a 301x501 data file containing Bz magnetic field values
FieldMap_Br.csv is a 301x501 data file containing Br magnetic field values
FieldMap_z.csv is a 1x501 file containing Z cordinates
FieldMap_r.csv is a 1x301 file containing R cordinates
there is no variation in theta so it can be assumed zero.
I want to get a output in the form of (X,Y,Z,BX,BY,BZ) in a tabular form.Below is my code. However I am not able to figure out a way to make the meshgrid same size for both directions
clc;
clear all;
close all;
Br=importdata('FieldMap_Bz.csv');%%Radial Magnetic field values
Bz=importdata('FieldMap_Br.csv');%%Axial Magnetic field values
Z=importdata('FieldMap_z.csv');
Radial=importdata('FieldMap_r.csv');
R=Radial(:,1);%%Radial Cordinates
Z=Z(1,:);%%Axial Cordinates
theta=0;
X=Radial*cos(theta);
Y=Radial*sin(theta);
Z=Z;
Bx=Br*cos(theta);
By=Br*sin(theta);
Bz=Bz;
I look forward to everyones suggestion and help.
thanks
Bharat

답변 (1개)

Richard Burnside
Richard Burnside 2023년 6월 21일
편집: Richard Burnside 2023년 6월 21일

0 개 추천

Bharat,
Have you looked at the pol2cart function? I think it should work for you here.

댓글 수: 2

yes I did. But how should I reshape the arrays because they are not same size.
FieldMap_Bz.csv is a 301x501 data file containing Bz magnetic field values
FieldMap_Br.csv is a 301x501 data file containing Br magnetic field values
FieldMap_z.csv is a 1x501 file containing Z cordinates
FieldMap_r.csv is a 1x301 file containing R cordinates
and theta is assumed to be zero.
Hmm...
Its hard to say how to stitch this data together without seeing it. Its a planar slice of a cylinder so possibly it is 301 r coordinates and 501 z coordinates with orthogonal B-field vectors at each (r,z) coordinate pair.

댓글을 달려면 로그인하십시오.

카테고리

질문:

2023년 6월 21일

댓글:

2023년 6월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by