Legend for matrix plot
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Adam
le 2 Sep 2016
This works fine for me. Do you have a variable with the name 'legend' that is hiding the function?
which -all legend
will show if this is the case. Then removing the variable will allow the function to be 'seen' again and all should work fine.
Try to make sure you never name variables after builtin functions. If you are unsure when naming a variable you can always use the 'which' command e.g.
which size
if you were considering to name a variable 'size'. then you will see this is a bad idea as it will show up a function of this name. Equally you should not name variables the same as your own functions for the same reason.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Legend dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!