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

1 回表示 (過去 30 日間)
Foad Sojoodi Farimani
Foad Sojoodi Farimani 2021 年 5 月 21 日
回答済み: Star Strider 2021 年 5 月 21 日
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.

採用された回答

Star Strider
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)))
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)])
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by