I want a program in which the user enters the function and the program display or plot that function

1 visualización (últimos 30 días)
val=input("Enter Function",'s');
func= str2func( ['@(x) ' val ] );
x=(1:5);
y=func(x);
disp(y)
this is an example code that i wrote but code does not support x^2 and other amount of x^"any number"

Respuesta aceptada

Antoni Garcia-Herreros
Antoni Garcia-Herreros el 10 de Mayo de 2023
Editada: Antoni Garcia-Herreros el 10 de Mayo de 2023
Hello Amir,
When you input your function you need to add the dot , just like this: x.^n

Más respuestas (0)

Categorías

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

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by