a easier way to do vector
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Johnny
el 8 de Dic. de 2019
Comentada: Stephen23
el 8 de Dic. de 2019
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 comentarios
Respuesta aceptada
Stephen23
el 8 de Dic. de 2019
Editada: Stephen23
el 8 de Dic. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!