Output doesn't display a value, just an empty space.
5 ビュー (過去 30 日間)
古いコメントを表示
So, I've got 2 pulses (imp and S0) and their sum (Si). I've got to find minimum of sum (Si). And I approximate the sum with a polynome. I took derivatives (1-st and 2-nd order) of the sum and polynome.
I analyze derivatives, and decided to look for minimum of sum (Si), polynome and 2-nd derivatives.
But, in some cases the result is just empty, but size of variable is 1x999 double.

lb = -5;
ub = 15;
x_imp = linspace(lb, ub, 1001);
x = linspace(lb, ub, 1001);
imp = sech(x_imp);
S0 = sech(x-10);
imp1 = sech(x - 1);
S1 = 0.5 * (imp1 + S0);
xmin = -1;
xmax = 10;
% find inflection point Si
range_x = x(x>=xmin & x<=xmax);
range_S1 = S1(x>=xmin & x<=xmax);
MinPtsS1 = islocalmin(range_S1);
fprintf ('x_S1 = %f , y_S1 = %f .\n', range_x(MinPtsS1), range_S1(MinPtsS1));
% polynom approximation pv
[p_S1, ~, mu] = polyfit(x, S1, 26);
pv_S1 = polyval (p_S1, x, [], mu);
% find inflection point of polynom pv
range_x = x(x>=xmin & x<=xmax);
range_pvS1 = pv_S1(x>=xmin & x<=xmax);
MinPts_pvS1 = islocalmin(range_pvS1);
fprintf('x_pvS1 = %f , y_pvS1 = %f .\n', range_x(MinPts_pvS1), range_pvS1(MinPts_pvS1));
% DIFF find inflection of diff2 Si, corresponding to inflection point of Si
dS1 = 20*diff (S1);
d2S1 = 10*diff(dS1);
range_x = x(x>=xmin & x<=xmin);
range_d2S1 = d2S1(x>=xmin & x<=xmin);
MinPts_d2S1 = islocalmin(range_d2S1);
fprintf('x_d2S1 = %f , y_d2S1 = %f .\n', range_x(MinPts_d2S1), range_d2S1(MinPts_d2S1));
% DIFF find inflection of diff2 polynom Si, corresponding to inflection point of Si
dpS1 = 20*diff(pv_S1);
dp2S1 = 20*diff(dpS1);
range_x = x(x>=xmin & x<=xmax);
range_dp2S1 = dp2S1(x>=xmin & x<=xmax);
MinPts_dp2S1 = islocalmin(range_dp2S1);
fprintf('x_dp2S1 = %f , y_dp2S1 = %f .\n', range_x(MinPts_dp2S1), range_dp2S1(MinPts_dp2S1));
0 件のコメント
採用された回答
Stephen23
2025 年 7 月 16 日
編集済み: Stephen23
2025 年 7 月 16 日
How many values fulfill your logical comparisons? Exactly one.
range_x = x(x>=xmin & x<=xmin);
range_d2S1 = d2S1(x>=xmin & x<=xmin);
should be
range_x = x(x>=xmin & x<=xmax);
range_d2S1 = d2S1(x>=xmin & x<=xmax);
Due to FPRINTF processing all input arguments in linear order you will also need to modify the FPRINTF input arguments (e.g. by defining a matrix), or use e.g. COMPOSE with column vectors.
There might be other bugs too...
10 件のコメント
Stephen23
2025 年 7 月 17 日
編集済み: Stephen23
2025 年 7 月 17 日
"... I need the min point of polynomial, around x = 5, which is not presented in all 4 methods.. "
X = linspace(-5, 15, 1001);
Y = 0.5 * (sech(X-1) + sech(X-10));
[p_S1, ~, mu] = polyfit(X, Y, 26);
pv_S1 = polyval(p_S1, X, [], mu);
dp_S1 = polyder(p_S1);
dpoly = @(xq) polyval(dp_S1, (xq-mu(1))./mu(2));
x_min = fzero(dpoly, 5)
y_min = interp1(X,Y,x_min)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!