Hello
I have a following simple code with two sine waves
t=[0:0.001:0.03];
x=10*sin(2*pi*50*t+10);
y=5*cos(2*pi*50*t-30);
plot(t,x,'bk-',t,y,'b.-')
I have two questions regardng the plot
1. Is there a way to print an index (1,2,3...) of a datapoint on the plot?
2. Is there a way on how to make the lines Bold or to increase thickness?
Plot help instruction do not work (or I am using it wrong). Any examples fro
both would be much appreciated.
Thanks
--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Hi Blaz,
1) Yes, but there isn't a built in way, as far as I know. Using a bit of a hack (I'm never great at manipulating cell arrays), you can use the text command to add text (in this case the indices) to specific points on the plot, like so:
indices = 1:length(t);
indices_cell = mat2cell(indices, 1, ones(1, length(t))); % there is probably a better way to make a cell array
indices_strings = cellfun(@num2str, indices_cell, "UniformOutput", false); % takes every number in the cell array and maps it to a string
text(t, x, indices_strings) % adds the strings to the coordinates (t,x) you may want to adjust them by adding or subtracting some value to make it look nicer?
2) Change the linewidth property using the plot command, like so:
plot(t,x,'bk-','linewidth',4,t,y,'b.-','linewidth',8)
Hope this helps,
James Sherman Jr.