I want to plot 2d quiver plot from 3d data but get a syntax error
Mostra commenti meno recenti
clear;
nX = 7;
nY = 7;
nZ = 7;
gridSize = [nX nY nZ];
gridScaling = [1 1 1 1];
[X,Y,Z] = meshgrid(1:nX, 1:nY, 1:nZ);
X_labels = (X - worldCenter(2)) * gridScaling(2);
Y_labels = (Y - worldCenter(3)) * gridScaling(3);
Z_labels = (Z - worldCenter(4)) * gridScaling(4);
beta = cell(1,3);
for i = 1:3
beta{i} = zeros(nZ,nY,nX);
end
beta_x = zeros(gridSize);
beta_y = zeros(gridSize);
beta_z = zeros(gridSize);
for k = 1:gridSize(3)
for j = 1:gridSize(2)
for i = 1:gridSize(1)
beta{1}(k,j,i) = '<code determining the 1st component of the beta vector at coordinates i,j,k>';
beta{2}(k,j,i) = '<code determining the 2nd component of the beta vector at coordinates i,j,k>';
beta{3}(k,j,i) = '<code determining the 3rd component of the beta vector at coordinates i,j,k>';
end
end
end
quiver( X_labels, Y_labels, beta{1}( 4, 1:nY, 1:nX ), beta{2}( 4, 1:nY, 1:nX ), 0.7 );
The simplified code above doesnt work and I can't figure out why. I want to plot a slice of the vector field 'beta' at z == 4. I get "The size of Y must match the size of U or the number of rows of U.". But how can that be if it is set to nX by nY by definition?
Please help me to fix the problem.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Vector Fields in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
