Borrar filtros
Borrar filtros

convert code from excel to matlab

2 visualizaciones (últimos 30 días)
Brian Kirkland
Brian Kirkland el 11 de Dic. de 2021
Editada: Rena Berman el 13 de Dic. de 2021
How do I convert my excel code to matlab? The excel code below contains two "IF" statements and one "AND" statement.
x = IF(AND(2*abs(d)>3*abs(l-n), 2*abs(d)>3*abs(r-n)), 2*abs(d), IF(3*abs(l-n)>3*abs(r-n), 3*abs(l-n), 3*abs(r-n)))

Respuestas (1)

Chunru
Chunru el 11 de Dic. de 2021
% x = IF(AND(2*abs(d)>3*abs(l-n), 2*abs(d)>3*abs(r-n)), 2*abs(d), IF(3*abs(l-n)>3*abs(r-n), 3*abs(l-n), 3*abs(r-n)))
if (2*abs(d)>3*abs(l-n)) & (2*abs(d)>3*abs(r-n))
x = 2*abs(d);
elseif (3*abs(l-n)>3*abs(r-n)) & (3*abs(l-n))
x = 3*abs(r-n)));
end
  1 comentario
Walter Roberson
Walter Roberson el 11 de Dic. de 2021
Note that the above will only work if d and l and n and r are all scalar values. If arrays are being processed then different code would be needed.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by