Borrar filtros
Borrar filtros

simple code for the log computation

2 visualizaciones (últimos 30 días)
Tino
Tino el 25 de Abr. de 2019
Comentada: Star Strider el 25 de Abr. de 2019
Hello,
Please can anyone help me with a short code to do the following computation below
X = { 1, 2, 3, 5, 6}
M1 = log10(X(:,1));
M2 = log10(X(:,2));
M3 = log10(X(:,3));
M4 = log10(X(:,4));
Thanks in advance
Tino

Respuesta aceptada

Star Strider
Star Strider el 25 de Abr. de 2019
Since ‘X’ is a cell array, you first must convert it to a double array, here using ‘[X{:}]’:
X = { 1, 2, 3, 5, 6};
M = log10([X{:}])
producing:
M =
0 0.3010 0.4771 0.6990 0.7782
Please do not name them ‘M1’...‘M4’. Keep them as a single array, and refer to them that way. If you want them to be individual elements of a cell array, use the num2cell function.
  2 comentarios
Tino
Tino el 25 de Abr. de 2019
Thanks Star
Star Strider
Star Strider el 25 de Abr. de 2019
My pleasure.

Iniciar sesión para comentar.

Más respuestas (1)

Andrei Bobrov
Andrei Bobrov el 25 de Abr. de 2019
X = [1, 2, 3, 5, 6];
M = log10(X);

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by