a question about plotting
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Q.
I have many S seperately with different on lines on the plot, lines with different k have different colours and shapes. I change the coding to make it more efficient, but now I have no idea how to have a same plot of my original one.
1/ my original codes for S and k, and my original plotting codes
I = 1:100
k03 = 0.3
k1 = 1
k3 = 3
k5 = 5
k8 = 8
k13 = 13
k15 = 15
k18 = 18
k23 = 23
k25 = 25
k28 = 28
S03F = k03*log(I)
S1F = k1*log(I)
S3F = k3*log(I)
S5F = k5*log(I)
S8F = k8*log(I)
S13F = k13*log(I)
S15F = k15*log(I)
S18F = k18*log(I)
S23F = k23*log(I)
S25F = k25*log(I)
S28F = k28*log(I)
figure(1)
hold on
plot(S03F,'co-','markersize',3,'Displayname','k<1');
plot(S1F,'gs-','markersize',3,'Displayname','k=1');
plot(S3F,'gs-','markersize',3,'Displayname','k=3');
plot(S5F,'gs-','markersize',3,'Displayname','k=5');
plot(S8F,'gs-','markersize',3,'Displayname','k=8');
plot(S13F,'md-','markersize',3,'Displayname','k=13');
plot(S15F,'md-','markersize',3,'Displayname','k=15');
plot(S18F,'md-','markersize',3,'Displayname','k=15');
plot(S23F,'rp-','markersize',3,'Displayname','k=23');
plot(S25F,'rp-','markersize',3,'Displayname','k=25');
plot(S28F,'rp-','markersize',3,'Displayname','k=28');
title({'Stevens Law:Power Function'...
'\fontsize{9}Relaitionship Between Subjective and Actual Stimulus Magnitude'...
'\fontsize{9}\color{blue} Under Various k Value'});
lgd = legend ('Location','northwest');
lgd.NumColumns = 4;
lgd.FontSize = 6;
hold off
2. the codes now for S and k
I = 1:100;
kV = [0.3;1;3;5;8;13;15;18;23;25;28];
SV = kV.*log(I)
0 commentaires
Réponse acceptée
FraFal
le 8 Déc 2019
Hi,
if you want to mantain your plot design, you can indexing your array. As example:
figure(1); hold on:
plot(SV(1), 'co-','markersize',3,'Displayname','k<1');
plot(SV(2),'gs-','markersize',3,'Displayname','k=1');
...
hold off
BR,
FraFal
2 commentaires
FraFal
le 8 Déc 2019
yes, sorry. Your output data is a matrix (it's a product-vector between 2 arrays).
In this way, you plot only one point/data of the array. If you want to plot data of each array, you have to define something like that: SV(: , 1) ...or SV(1,:).. depending on how your matrix data was defined. In this way for each row/column, you plot the respective column/row.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots 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!