Converting cylindircal data into regular cartesian grid

1 次查看(过去 30 天)
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
Bharat,
Have you looked at the pol2cart function? I think it should work for you here.
  2 个评论
BHARAT SINGH
BHARAT SINGH 2023-6-21
yes I did. But how should I reshape the arrays because they are not same size.
Richard Burnside
Richard Burnside 2023-6-21
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by