Legend for matrix plot
이전 댓글 표시
Hi. I have 3 matrixes. The first one contains measured frequencies:
freqs =
5 6 7
For each frequency I have x and y values:
x =
0.0116 0.0106 -0.0335
1.0986 1.0385 0.9020
2.0674 1.9955 1.9334
2.9450 3.0869 3.0334
4.0941 3.9551 4.0341
4.9456 4.9273 4.9743
6.0086 5.9592 6.0323
6.9813 7.0303 7.0465
7.9971 8.0223 8.0208
9.0282 8.9445 8.9044
10.0000 9.9224 10.0955
y =
-292 -286 -299
-283 -277 -295
-274 -267 -292
-266 -256 -285
-254 -245 -278
-244 -238 -272
-232 -227 -259
-224 -218 -249
-215 -210 -239
-208 -204 -231
-202 -199 -219
And to plot y vs x for each frequency i simply do:
p=plot(x,y)
which returns
p =
3x1 Line array:
Line
Line
Line
This plot is exactly as how like it. Now however. I can't put a legend here. For instance
legend('f1=5','f2=6','f3=7')
Returns the error:
Index exceeds matrix dimensions.
What can I do? It feels like I have tried everything..
댓글 수: 3
Adam
2016년 9월 2일
This works fine for me. Do you have a variable with the name 'legend' that is hiding the function?
What does
which -all legend
show?
Björn Persson
2016년 9월 2일
Adam
2016년 9월 2일
I will add my comment as an answer then in case it helps anyone else too.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!