Q:

Plotting vectors in matlab

I have this situation and I can't solve it in the proper way. The problem is this:
I have 3 vectors:

Vector1 = [name1 name2 name3 name4 ... nameN] (string names)
Vector2 = [time1 time2 time3 time4] (Double)
Vector3 = [time1:name4  time2:name1 time3:name1 time4:name1] (double:String)

I want to do the following in matlab:
1- Put Vector 1 in Y axis with  names
        - I could do it with this code:   
   set(gca, 'YTick',1:N, 'YTickLabel',Names(:,1))

2- put Vector 2 in X axis with, to simulate time line
3- Once we have both axis X&Y I'd like to use the 3 Vector to plot point in the graph
For example, 3 Vector contains secuentially timestamps and in each timestamp is executed the nameN, so I'd like to plot a dot in the graph using 3 vector as input.
Any suggestion?Thanks in advance 

A:

You need to convert the names in vector3 to numbers, then you can call the plot command.
For example
names = {'a','b','c','d'}; %# use a cell array (curly brackets) for strings
time = [10 20 30 40 50];
data = {10,'d';20,'b';40,'c'}

%# convert data to numeric xData, yData
xData = cell2mat(data(:,1));
[dummy,yData] = ismember(data(:,2),names);

%# plot
plot(xData,yData,'.') %# plot dots
set(gca,'YTick',1:length(names),'YTickLabel',names,'XTick',time)

%# make sure the axes limits aren't too tight
xlim([0,60]),ylim([0,5])

