how can I plot a cartesian grid grid of 100*30 size with stretching in matlab

조회 수: 1 (최근 30일)
Amal Fennich
Amal Fennich 2020년 3월 18일
댓글: Amal Fennich 2020년 3월 18일
Is that code correct ? also
close all;
clc;
Mi=0.5;
T=300;
P=1;
gamma = 1.4;
R=287;
vinf = sqrt(gamma*R*T)*Mi;
Nx = 100; % x dimension
Ny = 30; % y dimension
Nxy= Nx*Ny;
% step sizes
dx = 1;
dy = 1;
x = 1:dx:Nx; % x axis
y = 1:dy:Ny; % y axis
%set grid location
for j=1:Ny
for i=1:Nx
x(i)=single(i-1)*dx;
y(j)=single(j-1)*dy;
end
end

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 3월 18일
I guess you want something like this
[x,y] = meshgrid(1:100, 1:30);
  댓글 수: 4
Ameer Hamza
Ameer Hamza 2020년 3월 18일
Can you show, in which format do you want the grid.
Amal Fennich
Amal Fennich 2020년 3월 18일
Nx = 100; % x dimension
Ny = 30; % y dimension
Nxy= Nx*Ny;
% step sizes
dx = 1;
dy = 1;
x = 1:dx:Nx; % x axis
y = 1:dy:Ny; % y axis
% PLOT ARC
circx= linspace(0,1,40);
circy= sqrt(8.35^2 - (circx-.5).^2)-8.335;
plot(circx, circy) % Draw An Arc
axis([-0.5 1.5 -.1 .1]) % Set Axis Limits
hold on;
[xx,yy]=meshgrid(x,y); %develop grid based on 2 (x and y) arrays of different size
z=zeros(size(xx)); %generate z as a matrix of zeros (same size as meshgrid)
pcolor(xx,yy,z); %plots the 3 dimensions as a '2d plot' of meshgrid at z=0
% view(1) %changes the 3d default view to a 2d for xy plane
xlim([1 100])
ylim([1 30])
hold off ;

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

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by