How to calculate a printed arithmetic
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ernest Adamtey
el 31 de Jul. de 2021
Comentada: Chunru
el 1 de Ag. de 2021
for A=1:3
if A==1
fprintf('2')
elseif A==2
fprintf('+')
elseif A==3
fprintf('3')
end
end
I want represent numbers and operations with code numbers. But when I run this code I get an output
2+3>>
but it doesnt give me the solution. I want to get an output which gives me 5. Please help
0 comentarios
Respuesta aceptada
Chunru
el 31 de Jul. de 2021
str = [];
for A=1:3
if A==1
str = [str sprintf('2')];
elseif A==2
str = [str sprintf('+')];
elseif A==3
str = [str sprintf('3')];
end
end
str
eval(str)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown 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!