Undefined function or variable 'x' - Never seen before, mega frustrating!
Mostra commenti meno recenti
So I've been using MATLAB for one of my University subjects this whole year without fault. It really is some great software. Fairly easy to use, and incredibly in-depth.
But yesterday, when I sat down to start work on a small assignment I had, I ran into a bit of a snag that I haven't been able to solve until now. It is frustrating me to the point of wanting to jump off a cliff.
Long story short, the simple command window line
>> eqn1 = 5*x + 3*y == 2
gives me an error reading
Undefined function or variable 'x'.
This is frustrating because just the other week I was able to do exactly that without any problem at all. MATLAB quite gladly ran
eqn1 = 5*x + 3*y == 2
eqn2 = 3*x + 2*y == 10
[A,B] = equationsToMatrix ([eqn1,eqn2],[x,y])
...meaning I had two matrices
A
5 3
3 2
and B
2
10
But now it doesn't even want to assign any values to my equation-variables.
1 Commento
@Adebayo Akinfenwa: there are several possible reasons for why it worked before, but all of them come under the category of x was already defined before your ran that code.
However that is not really the point of MATLAB: it is not required to predefine any variables or specify them as variables in a function. The basic (easiest and fastest) way to use MATLAB is to simply define numeric values (scalar/vector/matrix) and perform operations on them: this is how all numeric calculation software works:
Risposta accettata
Più risposte (1)
Image Analyst
il 30 Mag 2016
Before you had previously defined x and y, though perhaps you did it without knowing it for forgot. Try defining them:
x = 1; % Whatever....
y = -1; % Whatever...
eqn1 = (5*x + 3*y == 2) % This will be a logical (true or false) result.
eqn2 = 3*x + 2*y == 10
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!