contourf doesn't plot left side of the figure in log scale!
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Foad Sojoodi Farimani
el 21 de Mayo de 2021
Respondida: Star Strider
el 21 de Mayo de 2021
consider the code:
close all;
clear;
clc;
Elasticity = 58.34E9; % GPa
[force, radius] = meshgrid(linspace(0, 1), linspace(1, 60) * 1E-3); % [N, m]
delta = (3 * force / 4 / Elasticity).^(2 / 3) ./ (radius).^(1 / 3);
stiffness = 2 * Elasticity * sqrt(radius .* delta);
pressure = (6 * force .* (Elasticity ./ radius).^2).^(1 / 3) / pi;
stiffness_min = (1000 * 2 * pi)^2 * 0.150 / 3;
stiffness_plot = stiffness;
stiffness_plot(stiffness < stiffness_min) = nan;
stiffness_plot(503E6 < pressure) = nan;
contourf(force, radius, stiffness_plot, 'ShowText', 'on');
set(gca, 'XScale', 'log');
xlim([0.01 force(end)])
the result is
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/625518/image.png)
as expected. However if I change the line
[force, radius] = meshgrid(linspace(0, 10), linspace(1, 60) * 1E-3); % [N, m]
I get the plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/625523/image.png)
where the left side of th efigure is missing. I would appreciate if you could help me know what is the problem and how I can fix it.
0 comentarios
Respuesta aceptada
Star Strider
el 21 de Mayo de 2021
The problem is the resolution in the ‘force’ vector.
For example, check the increments —
format long
f1 = mean(diff(linspace(0, 1)))
f2 = mean(diff(linspace(0, 10)))
f3 = mean(diff(linspace(0, 10, 1000)))
format short
Increasing the number of elements in the (0, 10) linspace call, therefore approsimately restoring the original resolution, results in the original behaviour.
Elasticity = 58.34E9; % GPa
[force, radius] = meshgrid(linspace(0, 10, 1000), linspace(1, 60) * 1E-3); % [N, m]
delta = (3 * force / 4 / Elasticity).^(2 / 3) ./ (radius).^(1 / 3);
stiffness = 2 * Elasticity * sqrt(radius .* delta);
pressure = (6 * force .* (Elasticity ./ radius).^2).^(1 / 3) / pi;
stiffness_min = (1000 * 2 * pi)^2 * 0.150 / 3;
stiffness_plot = stiffness;
stiffness_plot(stiffness < stiffness_min) = nan;
stiffness_plot(503E6 < pressure) = nan;
contourf(force, radius, stiffness_plot, 'ShowText', 'on');
set(gca, 'XScale', 'log');
xlim([0.01 force(end)])
.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Contour Plots 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!