Hello. I'd like to ask you how can I make the typical mesh and its 3D figure in the following code:
clc; clear; close all;tic;h0 = 1.0;g = 20;a1 = 1; % dimensionless amplitude
a2 = 0.1; % dimensionless amplitudec0 = sqrt(g*h0); % dimensional velocity
v1 = sqrt( 1 + 2*a1/3);P1 = 2*a1*h0/3;Q1 = sqrt(a1/2)/(v1*h0);R1 = v1*sqrt(g*h0);%
x1 = 0; % initial position
beta = 0.1;it_M = 21;ep = 16;%%Domain
% x domain
x_max = 20; x_min = -10;% x = (x_min:0.5: )
N1 = 61;x = linspace(x_min,x_max, N1)';dx = x(2) - x(1);% t domain
t_max = 1; N2 = 11;t = linspace(0, t_max, N2)';dt = t(2) - t(1);% k domain
k_max = 2; N3 = 201;k = linspace(0, k_max, N3)'*pi;dk = k(2) - k(1);% omega
ga = sqrt( (c0^2*k.^2 + beta)./(1+h0^2*k.^2/3) );%%linear solution
u_con = zeros(N1, N2);for n2 = 1:N2 u_con(:, n2) = P1*(sech(Q1*(x - R1*t(n2) - x1))).^2 ;endfigure;surf(x, t, u_con', 'linestyle', 'none')xlabel('$x$', 'Interpreter', 'latex', 'fontsize', 18)ylabel('$t$', 'Interpreter', 'latex', 'fontsize', 18)zlabel('$\eta_{linear}$', 'Interpreter', 'latex', 'fontsize', 18)axis tightview(-10, 70)set(gca,'fontsize', 18,'FontName','times')R1 = -5; R2 = 5;dxo = 0.5; dxn = 0.1;xnew = [x_min:dxo:R1, R1+dxn:dxn: R2, R2+dxo:dxo:x_max]';eta1n = P1*(sech(Q1*(xnew - x1))).^2; % soliton
eta2n = 2*P1*Q1*R1*(sech(Q1*(xnew - x1))).^2.*tanh(Q1*(xnew - x1));figure;plot(xnew, eta1n, 'k*-', 'markersize', 3)hold onplot(xnew, eta2n, 'ro-', 'markersize', 3)hold onxlabel('$x$', 'Interpreter', 'latex', 'fontsize', 18)ylabel('$\eta_2$', 'Interpreter', 'latex', 'fontsize', 18)axis tight% ylim([-0.1 0.1])
set(gca,'fontsize', 18,'FontName','times')N1n = (R1 - x_min)/dxo + (R2 - R1)/dxn + (x_max - R2)/dxo + 1;u_new = zeros(N1n, N2);x_ax = u_new;R1 = -5; R2 = 5;dxo = 0.5; dxn = 0.1;for n2 = 1:N2 x_ax(:, n2) = [x_min:dxo:R1 + 5*dt*(n2-1), R1+5*dt*(n2-1)+dxn:dxn: R2+5*dt*(n2-1), ... R2+dxo+5*dt*(n2-1):dxo:x_max]'; u_new(:, n2) = P1*(sech(Q1*(x_ax(:, n2) - R1*t(n2) - x1))).^2 ; end
If you process it you can find a soliton which looks likes a bell. I want to make the mesh as attached figure. That is, in the region [R1, R2], the mesh is finer than that of outside one and it moves according to the moving solitary wave. I want to concentrate only on the significant region.
I hope to plot it as Figure 1 however I can't, so I hope you help me to improve it. I'm looking forward to hearing from you..^^
Best Answer