How can I plot the innermost contour?
이전 댓글 표시
clc;
clear;
L = 100;
v_origin = 10;
v_opposite = 20;
t = randi([1, 100]);
x_0 = @(t) 2*t + 2;
y_0 = @(t) t + 3;
k_ad = 10^(0.3591 * log10(v_origin) + 0.0952);
k_dt = 10^(0.5441 * log10(v_opposite) - 0.0795);
r_fort = (1 + 1.34 * sqrt(k_ad^2 + k_dt^2)) * L;
r_aft = (1 + 0.67 * sqrt(k_ad^2 + k_dt^2)) * L;
r_starb = (0.2 + k_ad) * L;
r_port = (0.2 + 0.75 * k_ad) * L;
syms x y;
segmentedFunction = @(m) (m < 0) * -1 + (m >= 0) * 1;
parameter = @(x,y) power(2*x / ((1 + segmentedFunction(x)) * r_starb - (1 - segmentedFunction(x)) * r_port), 2) + ...
power(2*y / ((1 + segmentedFunction(y)) * r_fort - (1 - segmentedFunction(y)) * r_aft), 2);
fcontour(parameter, [-400,400,-400, 400], 'LineWidth', 2);
채택된 답변
추가 답변 (1개)
L = 100;
v_origin = 10;
v_opposite = 20;
t = randi([1, 100]);
x_0 = @(t) 2*t + 2;
y_0 = @(t) t + 3;
k_ad = 10^(0.3591 * log10(v_origin) + 0.0952);
k_dt = 10^(0.5441 * log10(v_opposite) - 0.0795);
r_fort = (1 + 1.34 * sqrt(k_ad^2 + k_dt^2)) * L;
r_aft = (1 + 0.67 * sqrt(k_ad^2 + k_dt^2)) * L;
r_starb = (0.2 + k_ad) * L;
r_port = (0.2 + 0.75 * k_ad) * L;
syms x y;
segmentedFunction = @(m) (m < 0) * -1 + (m >= 0) * 1;
parameter = @(x,y) power(2*x ./ ((1 + segmentedFunction(x)) .* r_starb - (1 - segmentedFunction(x)) .* r_port), 2) + ...
power(2*y ./ ((1 + segmentedFunction(y)) .* r_fort - (1 - segmentedFunction(y)) .* r_aft), 2);
fcontour(parameter, [-400,400,-400, 400], 'LineWidth', 2,'LevelList',0.5);
댓글 수: 3
Dyuman Joshi
2023년 12월 6일
@Cris LaPierre, How did you get the value of 0.5?
(I assume you plotted the overall contour initially, got the value from the vector stored in the property LevelList through the handle of the fcounter plot and then used it)
And how to generalize the code for any contour function?
You'd have to know something about your data if you are only wanting to plot a single level. You can gain that insight either visually by plotting, or artificially through the use of min and max functions. Once you have that insight, it's just a matter of picking a point to highlight.
You could create a contour plot first and capture the output, then replot using the output you captured to set the level.
L = 100;
v_origin = 10;
v_opposite = 20;
t = randi([1, 100]);
x_0 = @(t) 2*t + 2;
y_0 = @(t) t + 3;
k_ad = 10^(0.3591 * log10(v_origin) + 0.0952);
k_dt = 10^(0.5441 * log10(v_opposite) - 0.0795);
r_fort = (1 + 1.34 * sqrt(k_ad^2 + k_dt^2)) * L;
r_aft = (1 + 0.67 * sqrt(k_ad^2 + k_dt^2)) * L;
r_starb = (0.2 + k_ad) * L;
r_port = (0.2 + 0.75 * k_ad) * L;
syms x y;
segmentedFunction = @(m) (m < 0) * -1 + (m >= 0) * 1;
parameter = @(x,y) power(2*x ./ ((1 + segmentedFunction(x)) .* r_starb - (1 - segmentedFunction(x)) .* r_port), 2) + ...
power(2*y ./ ((1 + segmentedFunction(y)) .* r_fort - (1 - segmentedFunction(y)) .* r_aft), 2);
fc = fcontour(parameter, [-400,400,-400, 400], 'LineWidth', 2);
LL = fc.LevelList
figure
fc = fcontour(parameter, [-400,400,-400, 400], 'LineWidth', 2,'LevelList',LL(1));
Dyuman Joshi
2023년 12월 6일
편집: Dyuman Joshi
2023년 12월 8일
Could you specify which/what method you followed to get the value 0.5?
카테고리
도움말 센터 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





