contourf doesn't plot left side of the figure in log scale!
1 次查看(过去 30 天)
显示 更早的评论
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
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:
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 个评论
采纳的回答
Star Strider
2021-5-21
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!