How to plot with lines in a for loop and use legends for each line?
Show older comments
Hello, I'm having trouble using the plot function to plot some values from my array. The problem is, it only shows points, but no lines connected between them.
Here is what my cell array looks like:
matrix{1} = 0.0274 0.0268 0.0275
matrix{2} = 0.0130 0.0128 0.0124
matrix{3} = 0.0111 0.0108 0.0113
matrix{4} = 0.0110 0.0107 0.0107
matrix{5} = 0.0109 0.0107 0.0107
matrix{6} = 0.0109 0.0107 0.0107
matrix{7} = 0.0109 0.0107 0.0107
matrix{8} = 0.0109 0.0107 0.0107
Using the following code produces only points but no lines.
for i = 1:8
for j= 1:3
plot(i, matrix{1}(1, j), '*');
hold on;
end
end

What am I doing wrong?
Also, how can I associate the lines (if working) with a legend?
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!