How to plot this equation to obtain the figure?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
soe min aung
el 18 de Dic. de 2019
Comentada: soe min aung
el 24 de Dic. de 2019
![Untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/254967/image.png)
![1-s2.0-S0307904X10002131-gr2.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/254968/image.jpeg)
1 comentario
Walter Roberson
el 18 de Dic. de 2019
You have a bit of a problem: your has three independent inputs, and one output, so you need a 4-dimensional plot . The plot c that you show is for a fixed time, t1, not the general equation.
If you have the Symbolic Toolbox, probably the easiest approach is to use a piecewise() equation, subs() in a fixed time, and fplot() the result. If you do not have the Symbolic Toolbox, either use logical indexing to construct your answer, or else just compute over the three y ranges separately and concatenate them together.
Respuesta aceptada
Walter Roberson
el 24 de Dic. de 2019
N = 50; %subdivisions per dimension
xmin = -1; xmax = 101;
ymin = -160; ymax = 160;
tmin = 0; tmax = 3600;
xvec = linspace(xmin, xmax, N);
yvec = linspace(ymin, ymax, N);
tvec = linspace(tmin, tmax, N);
[X, Y, T] = ndgrid(xvec, yvec, tvec);
maskx = 0 <= X & X <= 100;
masky1 = -150 <= Y & Y < -50;
masky2 = -50 <= Y & Y < 50;
masky3 = 50 <= Y & Y <= 150;
xi = zeros(size(X));
mask1 = maskx & masky1;
mask2 = maskx & masky2;
xi(mask1) = xi0 * v*T(mask1)/(2 * L) .* (1 - cos(pi/50*X(mask1))) .* (1 - cos(pi/100*(Y(mask1) + 150)));
xi(mask2) = xi0 * V*T(mask2) / L .* (1-cos(pi/50*X(mask2)));
xi(mask3) = xi0 * v*T(mask3)/(2 * L) .* (1 - cos(pi/50*X(mask3))) .* (1 - cos(pi/100*(Y(mask3) - 150)));
random_time_idx = randi(length(tvec));
random_time = tvec(random_time_idx);
x_for_t = X(:,:,random_time_idx);
y_for_t = Y(:,:,random_time_idx);
zi_for_t = xi(:,:,random_time_idx) / xi0;
surf(x_for_t, y_for_t, zi_for_t)
xlabel('x (km)');
ylabel('y (km)');
zlabel('$\frac{\zi(x,y,t1)}{\zi_0}', 'interpreter', 'latex')
title( sprintf('time = %.2f', random_time) );
1 comentario
Más respuestas (1)
soe min aung
el 23 de Dic. de 2019
3 comentarios
Walter Roberson
el 23 de Dic. de 2019
Do you have the symbolic toolbox? Did you read about piecewise? Did you read about logical indexing?
Ver también
Categorías
Más información sobre Assumptions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!