a easier way to do vector
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Is there any easier or more efficient way to calculate SF when there is different k?
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)
0 commentaires
Réponse acceptée
Stephen23
le 8 Déc 2019
Modifié(e) : Stephen23
le 8 Déc 2019
"Is there any easier or more efficient way to calculate SF when there is different k?"
Do NOT use numbered variables, they are a sign that you are doing something wrong (in particular, you are forcing meta-data into variable names).
A much more efficient use of MATLAB would be to use vectors:
I = 1:100; % square brackets do nothing here
kV = [0.3,1,3,5,8,13,15,18,23,25,28]; % row vector
SV = bsxfun(@times,kV,log(I(:))) % MATLAB versions <R2016b
SV = kV.*log(I(:)) % MATLAB versions >=R2016b
plot(I,SV)
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D 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!