selection of graph points
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a code that builds level lines for my function of two variables, I need to leave out of these points only those for which the values of 'd' stand apart from each other at a distance of 4.04, i.e. we have a vector of values for points [tv,dv] and we leave in it only the points we need and we are building a schedule. How can this be implemented?
%% initial conditions
% global k0 h_bar ksi m E C_2
Ef = 2.77*10^3;
Kb = physconst('boltzmann'); % 1.38*10^(-23)
m = 9.1093837*10^(-31);
Tc = 1.2;
ksi = 10^(-9);
h_bar = (1.0545726*10^(-34));
k0 = (ksi/h_bar)*sqrt(2.*m.*pi.*Kb.*Tc);
C_2 = 6.81;
t = linspace(0.1, 2,500);
D = linspace(2*10^(-9), 100*10^(-9),500);
d = D./ksi;
%d = linspace(2, 100,500);
%[TT,DD] = meshgrid(t,d);
%contour(TT, DD, @f_calc);
for i=1:numel(d)
for j = 1:numel(t)
F(i,j) = f_calc(t(j),d(i), k0, h_bar, ksi, m, C_2);
end
end
%plot(t,F)
figure
[c,h] = contour(t,d,F,[0 0]);
xlabel('d')
ylabel('t')
% tv = c(2, 2:end);
% dv = c(1, 2:end);
[tv,dv] = getContour0(c,h);
Q1 = [size(c); size(tv)]
figure
plot(dv, tv, mlbdt.VarName2, mlbdt.VarName1, 'ob');
%scatter(mlbdt.VarName2,mlbdt.VarName1, 'black');
xlabel('d')
ylabel('t')
grid
%mesh(t,d,F)
function F = f_calc(t, d, k0, h_bar, ksi, m, C_2)
% global k0 h_bar ksi m C_2
%{
if 45 <= d && d <= 52
nD = floor(375/(2*pi.*t*1.2) - 0.5)+1;
else
nD = floor(375/(2*pi.*t*1.2) - 0.5);
end
%}
nD = floor(375/(2*pi.*t*1.2) - 0.5);
F = 0;
for k = 0:nD
%F = F + 1/(2*k+1).*(k0.*real(((f_p1(k,t)-f_p2(k,t))./2))+(f_arg_2(k,t,d,k0)-f_arg_1(k,t,d,k0))./d);
F = F + 1/(2*k+1).*imag(f_lg(k,t,d,k0)+1i.*d.*k0.*((f_p1(k,t)-f_p2(k,t))./2)+1i*f_arg_1(k,t,d,k0)-1i*f_arg_2(k,t,d,k0));
end
%F = -F - 6.81;
F = -(1/d).*F - 7.826922968141167;
end
function p1 = f_p1(n,t)
p1 = ((1+1i)./sqrt(2)).*sqrt(t.*(2.*n+1));
end
function p2 = f_p2(n,t)
p2 = sqrt(3601+1i.*t.*(2.*n+1));
end
function arg_1 = f_arg_1(n,t,d,k0)
% global k0
arg_1 = angle(1+exp(-1i.*d*k0.*f_p1(n,t)));
end
function arg_2 = f_arg_2(n,t,d,k0)
% global k0
arg_2 = angle(1+exp(-1i.*d*k0.*f_p2(n,t)));
end
function n_lg = f_lg(n,t,d,k0)
% global k0;
arg_of_lg = (1+exp(-1i.*d.*k0.*f_p1(n,t)))/(1+exp(-1i.*d.*k0.*f_p2(n,t)));
n_lg = log(abs(arg_of_lg));
end
function [xv,yv] = getContour0(M,C) % получение двух выходных значений от функции getContour0
Levels = C.LevelList
for k = 1:numel(Levels)
idx = find(M(1,:) == 0);
ValidV = rem(M(2,idx),1) == 0;
StartIdx{k,:} = idx(ValidV);
VLen{k,:} = M(2,StartIdx{k});
% Q3 = numel(StartIdx{k})
for k1 = 1:numel(StartIdx{k})
% Q4 = StartIdx{k}(k1)
idxv = StartIdx{k}(k1)+1 : StartIdx{k}(k1)+VLen{k}(k1); % Index For Contour 'k1'
xc{k1} = M(1,idxv);
yc{k1} = M(2,idxv);
end
end
xy = [cell2mat(xc); cell2mat(yc)].'; % .' обменивается индексом строки и столбца для каждого элемента. Транспонирование
xy = sortrows(xy,2);
xv = xy(:,1).';
yv = xy(:,2).';
% figure
% plot(xv, yv, '-r')
% grid
% title('Test Plot')
end
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!