imfreehand によって取得された軸に多数のポイントをプロットするために、interp1 (またはデシメートまたはリサンプル) の正しいサンプリング レートを見つけようとしています。
最初に何かをプロットします(正弦固有のものではないもの)
bands=1:20;plot(bands,sin(bands));
hax=gca;
次に、次のように軸上に imfreehand で何かを描きます。
imfreehand('Closed',0);
imfreehand オブジェクトからデータ部分(サイズ 1x413)を抽出 し、元の線の長さでそれらをプロットしようとしましたが、スケーリングが間違っています ...
data=get(hfree);
xydata=get(data.Children(4));
% x=xydata.XData;
y=xydata.YData;
len=length(y);
x=1:len;
newlen=length(bands);
scale=(len-1)/(newlen-1);
xx=1:scale:len;
yy=interp1(x,y,xx,'spline');
line(1:length(yy),yy(1:length(yy)),...
'LineWidth',4,...
'Color',[.8 .8 .8],...
'Parent',hax);
ヒントはありますか??
また、提案されたダウンサンプルと同じ結果..
for i=4:1:15 %just testing numbers
yy = downsample(y,i);
h=line(1:length(yy),yy(1:length(yy)),...
'LineWidth',1.2,...
'Color',[.8-i/100 .8-i/100 .8-i/100],...
'Parent',hax);
if length(bands)==length(yy)
set(h,'Color',[0 0 0], 'LineWidth',2);
end
end
ヒントはありますか?? x2