Search code examples
matlabmatlab-figuredrawfigure

Is it possible to plot a figure with arrows as shown in image attached in MATLAB?


Can I draw such a plot in Matlab? If not what would be the right software to draw it? Later, I need to paste figure in MS word file.

image


Solution

  • Sure, you need the annotation function, e.g.

    figure('Color','w');
    plot(-pi:0.01:pi,sin(-pi:0.01:pi));
    ax=gca();
    set(ax,'YAxisLocation','left','XAxisLocation','bottom','Box','off','XTick',[],'YTick',[])
    annotation('textarrow',[0.4,0.5],[0.4,0.5],'String','P')
    annotation('arrow',[ax.Position(1),sum(ax.Position([1,3]))],ax.Position([2,2]),'LineWidth',0.5);
    annotation('arrow',ax.Position([1,1]),[ax.Position(2),sum(ax.Position([2,4]))],'LineWidth',0.5);
    annotation('textbox',[ax.Position(1)-0.05,sum(ax.Position([2,4]))-0.05,0.05,0.05],'String','Q','EdgeColor','none')
    annotation('textbox',[sum(ax.Position([1,3]))-0.05,ax.Position(2)-0.05,0.05,0.05],'String','R','EdgeColor','none')
    

    enter image description here