Data Reshape for Contour Plot
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I'm facing a few problems while data reshaping. I have velocity values in a cartesian coordinate system (x,y,z) . The values are at the surface of a cylinder with a defined radius.
Therefore a transformation into cylinder coordinates to plot the data as 2D contour (Angle and Height) is suitable.
My Problem is that I have all the necessary data in the file 'TransformedData.txt' but it is not the required format for contourf.
I tried to reshape the data inspired by this post: (https://de.mathworks.com/matlabcentral/answers/421043-contour-plot-based-on-xyz-data) but it's still not working.
clc,close all
clearvars
filename='RawDataCFXPost.xlsx';
% Data Transformation
x=xlsread(filename,'A3:A36003');% Cartesian Coordinate x
y=xlsread(filename,'B3:B36003');% Cartesian Coordinate y
z=xlsread(filename,'C3:C36003');% Cartesian Coordinate z
ZData=xlsread(filename,'D3:D36003');% Velocity Value v
[theta,rho,z] = cart2pol(x,y,z);% Coordinate Transformation from Cartesian to Clyinder Coordinate System
A=[theta,rho,z,ZData];% Array with Transformed Data
writematrix(A,'TransformedData.txt','Delimiter',' ');
type TransformedData.txt;
% Data Reshape
Data = load('TransformedData.txt');
[Du,D1] = unique(Data(:,1));
Dd = diff(D1);
DataNew = reshape(Data, Dd(1), [], size(Data,2));
Angle = DataNew(:,:,1);
Height = DataNew(:,:,3);
Velocity = DataNew(:,:,4);
% Contour Plot
figure
contourf(Angle, Height, Velocity)
Maybe someone has a clue to solve this issue.
With best regards
Steffen
0 Kommentare
Akzeptierte Antwort
KSSV
am 20 Sep. 2024
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1776380/RawDataCFXPost.xlsx');
[theta,rho,z] = cart2pol(T.(1),T.(2),T.(3));
x = linspace(min(theta),max(theta),500) ;
y = linspace(min(rho),max(rho),500) ;
z = T.(4) ;
[X,Y] = meshgrid(x,y) ;
Z = griddata(theta,rho,z,X,Y) ;
contourf(X,Y,Z)
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!