contourf doesn't plot left side of the figure in log scale!
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Foad Sojoodi Farimani
am 21 Mai 2021
Beantwortet: Star Strider
am 21 Mai 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

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 Kommentare
Akzeptierte Antwort
Star Strider
am 21 Mai 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!