Filter löschen
Filter löschen

combine Input with formula

1 Ansicht (letzte 30 Tage)
Karel
Karel am 26 Jul. 2012
I have written the folowing function:
function [ sort1 , sort2 ] = front(x,N)
Y1=input('frontière inférieure: ','s') ;
s1=eval(Y1);
Y2=input('frontière supérieure: ','s');
s2=eval(Y2);
[Non important part of the function]
end
The idea is that the user can input either a number, or an expression (example given : y2 = (x^2-36) and y1=0
However, when I run the program, I get the folowing error:
frontière inférieure: 0
frontière supérieure: (36-x^2)
??? Error using ==> mpower
Inputs must be a scalar and a square matrix.
Error in ==> front at 6
s2=eval(Y2);
Error in ==> principal_1 at 18
[y1,y2]=front(xtab,n);
What should I use instead of Input?

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 26 Jul. 2012
try use
s2=eval(vectorize(Y2));
  1 Kommentar
Karel
Karel am 26 Jul. 2012
It worked, but I don't understand why, could you explain pplease?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by