Effacer les filtres
Effacer les filtres

How to check "Undefined function or variable..." error with a variable in Matlab program?

3 vues (au cours des 30 derniers jours)
Tuoi
Tuoi le 23 Août 2013
I have code as follows:
for i=1:3
M=Mtmp(i)+(Mtmp(i+1)-Mtmp(i))*(t-t(i))/(t(i+1)-t(i));
end
And, Mtmp(i) and t(i) are two arrays which are defined in previous code snippet.
I run that code and receive an error: Undefined function or variable 'M'
I think, in Matlab, we can use a variable that we do not have to declare one, why do I receive that error? Thanks.

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 23 Août 2013
I am sure the error does not concern those lines of code. Post the entire code, maybe there is another line where M is used at the right of your expression.
  2 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 24 Août 2013
[Tuoi commented]
Hi Azzi, I try to display the value of M by disp() function, I put the command line:
disp(['M= ',num2str(M)]);
after the above code (my post 1#), and run it, it generate that error (at disp() function). I hope you help me. Thanks.
Azzi Abdelmalek
Azzi Abdelmalek le 24 Août 2013
If M is defined, your code is correct. For example:
M=[1 2 3]
disp(['M= ',num2str(M)]);
Check If M is defined by typing M in Matlab command Windows

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by