Ploting from cell arrays to matching values and assigning labels

3 views (last 30 days)
The question heading might be confusing. sorry!
I'm using (2014b). I'm trying to figure out what I'm doing wrong here. probably everything :)
I have three cell arrays;
  • c1 - Nx1 cell array
  • c2 - Nx33 cell array
  • c3 - Nx33 cell array
  1. c1 is the "time". It corresponds to all the columns of c2 and c3 in a given row (e.g., c1(1,1) indicates the time for c2(1,:) and c3(1,:)).
  2. c2 bears the labels for c3 values (c2 values and c3 values are just random numbers).
  3. I want to plot c1 against c3 and label each matching point with c2.
  4. So to do this I tried struct / container.Map and normal "for" loop but all failed.
  • structure method;
Field1 = 'time';
Field2 = 'num';
Field3 = 'val';
value1 = c1(1:end,:);
value2 = c2(1:end,:);
value3 = c3(1:end,:);
S = struct(Field1,value1,Field2,value2,Field3,value3);
plot(S.time, S.val);
Error I'm getting : Error using struct Array dimensions of input '4' must match those of input '2', or be scalar.
Then I try;
S = struct(Field2,value2,Field3,value3);
plot(c1, S.val);
Error I'm getting : Error using plot Invalid first data argument
structure is just fine; if I type in S.val it will list me all the values in there and same for other two fields.
  • "for" loop
n = MaxCol;
for row = 1:numel(c3)
num = c2(row);
val = c3(row);
for col = 1:n
newrow = [c1 num(col) val(col)];
end
end
Error : Error using horzcat Dimensions of matrices being concatenated are not consistent.
  • just normal plot function
plot(c1(:,1),c3(:,5)); % at this point I'm not worried about labelling, just trying to see if it works at all.
Error: Error using plot Not enough input arguments.
plot(c1, c3);
Error: *Error using plot Size mismatch in Param Cell / Value Cell pair *
What is missing here in trying to plot c1 against c3 and label each matching point with c2?
Thank you

Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!