datatypes

8 ビュー (過去 30 日間)
sheen
sheen 2011 年 5 月 13 日
double e1,e2,e;
e1 = 107; e2 = e1 * 339;
disp(e2/e1)
error: The string being specified was neither 'single' nor 'double' ??? Undefined function or variable "e2".
Error in ==> ef at 1 float e1,e2,e;
ans =
101 49
??? Undefined function or variable "e2".
Error in ==> ef at 1 double e1,e2,e;
it is also giving problem with int and float?? what should i do to deal with this error?

採用された回答

Walter Roberson
Walter Roberson 2011 年 5 月 13 日
Your command
double e1,e2,e;
is equivalent to
double('e1')
e2
e
'e1' is a string, which is an array of character, and applying double to the array of character returns the numeric values of each of the characters: that happens to be 101 for 'e' and 49 for '2'. For more information on this, please see Command vs Function syntax
In MATLAB, one does not declare variables as being of a particular type: one just assigns values and the variable assumes the type of the values if the variable appears by itself (without any kind of indexing) in an assignment syntax.
  26 件のコメント
sheen
sheen 2011 年 5 月 21 日
d (P1, P2) =
M j j-1
∑ Q( (∑ (u )/T) - Q ((∑ (u )/T) * d v (P1,P2)
(j=1) (k=1) k (k=1) k j
i have written code for this eq.
j=1 is subscrtipt of first summation.and M is superscript of first summation and so on.i hope u will understand my problem now.for u with k as subscrit , i have taken size, modes and cost drivers.please tell me how to correct my code?
sheen
sheen 2011 年 5 月 21 日
j is superscript of second summation , j-1 is superscript of third summation.k=1 is subscript of second summation,k is of u, k=1 is of third summation and j issubscript of v.

サインインしてコメントする。

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2011 年 5 月 13 日
You don't need to declare them as double; it's automatic.
e1 = 107;
e2 = e1 * 339;
disp(e2/e1)
  6 件のコメント
sheen
sheen 2011 年 5 月 18 日
how to call fuzzy routine in this code ?
sheen
sheen 2011 年 5 月 21 日
how to use FIS output in this above similarity measure code?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by