contourf doesn't plot left side of the figure in log scale!

1 view (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 21 May 2021
The problem is the resolution in the ‘force’ vector.
For example, check the increments —
format long
f1 = mean(diff(linspace(0, 1)))
f1 =
0.010101010101010
f2 = mean(diff(linspace(0, 10)))
f2 =
0.101010101010101
f3 = mean(diff(linspace(0, 10, 1000)))
f3 =
0.010010010010010
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)])
.

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!