外挿値の取得について

36 views (last 30 days)
Yu
Yu on 20 Aug 2021
Commented: Yu on 20 Aug 2021
x軸にc, y軸にDをプロットし(実線)、y軸のデータがない部分を外挿でプロットしました(点線)。
外挿のコードは以下の通りです。
その際、以下のプロット図の点線のxy数値を取得したいのですが、どうすればよいでしょうか?
N = (linspace(1450,1460,100))';
c_ext = interp1(c, D, N, 'spline', 'extrap')

Accepted Answer

Hernia Baby
Hernia Baby on 20 Aug 2021
論理演算子を活用するのはいかがでしょうか?
以下、例を示します
x = linspace(0,10,100)';
y = sin(x) + rand(length(x),1);
xが5より小さいものだけを抜き出します
x1 = x(x<5);
y1 = y(x<5);
プロットします
plot(x,y,':',x1,y1,'--')
legend({'生データ','切り取り'});
  4 Comments
Hernia Baby
Hernia Baby on 20 Aug 2021
つまり繋げたいってことですかね
clc,clear,close all;
load('samples.mat');
ここで繋げてます
x_new = [N; c];
y_new = [c_ext; D];
[x_new_sort, idx] = sort(x_new);
y_new_sort = y_new(idx);
プロットして軸反転など行ってます
plot(x_new_sort,y_new_sort)
axis ij
xlim([1450 1540])
ylim([0 500])
Yu
Yu on 20 Aug 2021
sortとidxの組み合わせ方はとても勉強になりました。
お陰様で解決しました。
丁寧に説明くださりありがとうございました!

Sign in to comment.

More Answers (0)

Categories

Find more on 言語の基礎 in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!