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일

0 개 추천

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월 14일
thanx for such a nice description . but i am facing another problem in the following code:
% high weights of current project
j = [1.15,1.08,1.15,1.11,1.06,1.15,1.07,1.07,0.91,0.86,0.90,0.95,0.91,0.91,1.04];
% nominal weights of previous project
l = [1.00, 1.00 , 1.00 ,1.00, 1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00];
m = [1.05,1.12,1.2];
% float z[53]= [46,16,4,6.9,22,30,18,20,37,24,3,3.9,3.7,1.9,75,90,38,48,9.4,13,2.14,1.98,50,40,22,13,12,34,15,6.2,2.5,5.3,19.5,28,30,32,57,23,91,24,10,8.2,5.3,4.4,6.3,27,15,25,21,6.7,28,9.110];
t = 17;
% size
for i = 0:2
y = z(i)
end
% cost drivers
for k = 0 : j
x = j(k)
end
% project modes
for n = 0 : 2
a = m(n)
end
% sum of importance weights of current project
double s = a + x + y;
b = s / t;
for c = 0 : l
h = l(c)
end
% sum of importance weights of previous project
e = a + d+ y;
double f = e / t;
p = 24.5 ;
g = f * p;
% indivisual distance
d = b - g;
display (d)
error is:
??? Undefined command/function 'z'.
Error in ==> f at 21
y = z(i)
please tell me what shoud i do with it?
Walter Roberson
Walter Roberson 2011년 5월 15일
There are numerous errors in your code. Try
% high weights of current project
j = [1.15, 1.08, 1.15, 1.11, 1.06, 1.15, 1.07, 1.07, 0.91, 0.86, 0.90, 0.95, 0.91, 0.91, 1.04];
% nominal weights of previous project
l = [1.00, 1.00 , 1.00 ,1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00];
m = [1.05, 1.12, 1.2];
z = [46, 16, 4, 6.9, 22, 30, 18, 20, 37, 24, 3, 3.9, 3.7, 1.9, 75, 90, 38, 48, 9.4, 13, 2.14, 1.98, 50, 40, 22, 13, 12, 34, 15, 6.2, 2.5, 5.3, 19.5, 28, 30, 32, 57, 23, 91, 24, 10, 8.2, 5.3, 4.4, 6.3, 27, 15, 25, 21, 6.7, 28, 9.110];
%You might want a comma between the 9.1 and 10 that follows above??
t = 17;
%size
y = z(1:3);
% cost drivers
%for k = 0 : j %what was this intended to mean??
x = j(1:3); %guessing here
% project modes
a = m(1:3);
% sum of importance weights of current project
s = a + x + y;
b = s / t;
%for c = 0:1 %what was this intended to mean??
h = l(1:2); %guessing, but it is never used anyhow
% sum of importance weights of previous project
e = a + d + y;
f = e / t;
p = 24.5 ;
g = f * p;
% individual distance
d = b - g;
disp(d)
sheen
sheen 2011년 5월 15일
% high weights of current project
j = [1.15, 1.08, 1.15, 1.11, 1.06, 1.15, 1.07, 1.07, 0.91, 0.86, 0.90, 0.95, 0.91, 0.91, 1.04];
% nominal weights of previous project
l = [1.00, 1.00 , 1.00 ,1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00];
m = [1.05, 1.12, 1.2];
z = [46, 16, 4, 6.9, 22, 30, 18, 20, 37, 24, 3, 3.9, 3.7, 1.9, 75, 90, 38, 48, 9.4, 13, 2.14, 1.98, 50, 40, 22, 13, 12, 34, 15, 6.2, 2.5, 5.3, 19.5, 28, 30, 32, 57, 23, 91, 24, 10, 8.2, 5.3, 4.4, 6.3, 27, 15, 25, 21, 6.7, 28, 9.1,10];
t = 17;
%size
y = z(1:3);
%for k = 0 : j % its mean that I will take 12 values of matrix j in loop ok k and store these values in x, so I could use x in further calculations and whole 12 values will be used one by one by loop vie variable x.same is the case with other for loops..
x = j(k);
end % end is omitted by you? Is there no need to use it?
for n = 0 : 2
a = m(n)
end
% sum of importance weights of current project
s = a + x + y;
b = s / t;
for c = 0 : l
h = l(c)
end
% sum of importance weights of previous project
e = a + d + y;
f = e / t;
p = 24.5 ;
g = f * p;
% individual distance
d = b - g;
disp(d)
plz check it.
sheen
sheen 2011년 5월 15일
% high weights of current project
j = [1.15, 1.08, 1.15, 1.11, 1.06, 1.15, 1.07, 1.07, 0.91, 0.86, 0.90, 0.95, 0.91, 0.91, 1.04];
% nominal weights of previous project
l = [1.00, 1.00 , 1.00 ,1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00];
m = [1.05, 1.12, 1.2];
z = [46, 16, 4, 6.9, 22, 30, 18, 20, 37, 24, 3, 3.9, 3.7, 1.9, 75, 90, 38, 48, 9.4, 13, 2.14, 1.98, 50, 40, 22, 13, 12, 34, 15, 6.2, 2.5, 5.3, 19.5, 28, 30, 32, 57, 23, 91, 24, 10, 8.2, 5.3, 4.4, 6.3, 27, 15, 25, 21, 6.7, 28, 9.1,10];
t = 17;
%size
y = z(1:3);
%for k = 0 : j % its mean that I will take 12 values of matrix j in loop ok k and store these values in x, so I could use x in further calculations and whole 12 values will be used one by one by loop vie variable x.same is the case with other for loops..
x = j(k);
end % end is omitted by you? Is there no need to use it?
for n = 0 : 2
a = m(n)
end
% sum of importance weights of current project
s = a + x + y;
b = s / t;
for c = 0 : l
h = l(c)
end
% sum of importance weights of previous project
e = a + d + y;
f = e / t;
p = 24.5 ;
g = f * p;
% individual distance
d = b - g;
disp(d)
plz check it.
sheen
sheen 2011년 5월 15일
-66.6294 -25.1588 -8.7779
i have tried your recommended code with this change in code e = a+x+y; but it gives three values in output while it should be one value between 0 and 1 .what should i do???????
Walter Roberson
Walter Roberson 2011년 5월 15일
What was your original C code that you translated in to
for n = 0 : 2
a = m(n)
end
?
sheen
sheen 2011년 5월 18일
i didnt convereted c code but i am working on an algorithm , in which three modes are to entered as input.for those modes i took a for loop from 0 to 2 and stored it in array m by indexing it as n and storing this array in a.so i could use a in further formul for further calculations.
sheen
sheen 2011년 5월 18일
as u see in equation e = a+x+y , a is used for calculation, so here three modes are taken one by one and values are calculated. please tell me why answer is wrong i.e. -66.6294 -25.1588 -8.7779.
while i need one value between 0 and 1.what should i do?
sheen
sheen 2011년 5월 19일
please answer soon
Walter Roberson
Walter Roberson 2011년 5월 19일
How can you add three values, two of which are strictly greater than 1 and the other of which is strictly greater than 0, and expect to get an answer between 0 and 1 ???
sheen
sheen 2011년 5월 20일
% high weights of current project (cost drivers)
j = [1.15, 1.08, 1.15, 1.11, 1.06, 1.15, 1.07, 1.07, 0.91, 0.86, 0.90, 0.95, 0.91, 0.91, 1.04];
% nominal weights of previous project
l = [1.00, 1.00 , 1.00 ,1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00];
%mode
m = [1.05, 1.12, 1.2];
% size
z = [46, 16, 4];% 6.9, 22, 30, 18, 20, 37, 24, 3, 3.9, 3.7, 1.9, 75, 90, 38, 48, 9.4, 13, 2.14, 1.98, 50, 40, 22, 13, 12, 34, 15, 6.2, 2.5, 5.3, 19.5, 28, 30, 32, 57, 23, 91, 24, 10, 8.2, 5.3, 4.4, 6.3, 27, 15, 25, 21, 6.7, 28, 9.110];
t = 17;
%size
for z = 1:3
y{z} = 1 : z;
end
% cost drivers
for j = 1:15
x{j} = 1:j ;
end
% project modes
for m = 1 :3
a{m} = 1:m;
end
% sum of importance weights of current project
s = a{m} + x{j} + y{z};
b = s / t;
%cost drivers of previous project
for l = 1:2
h{l} = 1 :l;
end
% sum of importance weights of previous project
e = a{m} + h{l} + y{z};
f = e / t;
p = 24.5 ;
g = f * p;
% individual distance
d = b - g;
disp(d)
error:
??? Error using ==> plus
Matrix dimensions must agree.
Error in ==> efff at 36
s = a{m} + x{j} + y{z};
how to handle it? please reply soon.
Walter Roberson
Walter Roberson 2011년 5월 20일
In your case, I would start by going back and writing pseudo-code to describe what you are trying to do.
sheen
sheen 2011년 5월 21일
i want to calculate similarity between two projects.for which i have taken cost drivers,size and modes of those projects.
sheen
sheen 2011년 5월 21일
the pseudo-code of my m-file is given below:
Calculate similarity between software projects
Require Q , the Proportion of individual distances
Require k and j, describing software project
Require uk , the importance weight associated with Kth variable
Require M, describing the number of variables describing the software project
Require T, the total sum of all importance weights uk
Require dvj (P1,P2) , describing individual distance
Compute d(P1,P2)
S = ∑_(k=1)^j▒u_k , sum of current project’s importance weights
A = S/T, T is Total sum of all importance weights u_k
Q(A) where Q = 1
C = ∑_(j=1)^M▒〖Q(A)〗
Compute B = ∑_(k=1)^(j-1)▒u_k , sum of previous project’s importance weights
D1 = B/T
D2=D1(Q)
D3 = D2 (dvj (P1,P2)) where dvj (P1,P2) = {█(max min (µ_(Aj_k ) (P_1) ,µ_(Aj_k ) (P_2))@max-min aggregation@∑_k▒〖µ_(Aj_k ) (P_1) x µ_(Aj_k ) (P_2)〗@Sum-product aggregation)┤
D4= C – D3 \\ individual distance
sheen
sheen 2011년 5월 21일
please reply soon.
Walter Roberson
Walter Roberson 2011년 5월 21일
I cannot make out what some of those symbols are. In the expression for S, I cannot make out the symbol(s) between the ^j and the u_k . I also cannot tell why the underscore appears after the sigma.
In the expression for C, the same symbol appears to ocur. Then there is what seems to be some kind of brackets around Q(A) but I cannot tell if that is, for example, a symbol for "complex conjugate".
In the D3 like, thee is something I cannot make out between the { and the "(max", and those odd brackets appear again, and the line ends in something I am not sure I understand but which appears to be dash followed by "|" ?
I don't understand what the @ mean anywhere in the formula.
Please use only ASCII symbols, or else link to a URL that has the formula as a diagram and which indicates the meaning of any unusual symbols.
I probably will not reply all that soon: after weeks of nasty weather we finally have a warm clear evening, so I have yard-work duties.
sheen
sheen 2011년 5월 21일
can you give me your email address? becoz here symbols are not appearing in their original form .so i may send word file to you that have pseudo code. here i doesnt find option of file attach.
Matt Fig
Matt Fig 2011년 5월 21일
Why not just post the file to a file sharing site then share the link?
sheen
sheen 2011년 5월 21일
which file sharing site?
Walter Roberson
Walter Roberson 2011년 5월 21일
*Any* file sharing site that doesn't require us to register and log on to see the files.
sheen
sheen 2011년 5월 21일
?
Walter Roberson
Walter Roberson 2011년 5월 21일
Don't post people's email address without their permission.
I will see if I can put together a list of sites people use.
sheen
sheen 2011년 5월 21일
ok.i m really sorry sir.
Walter Roberson
Walter Roberson 2011년 5월 21일
See http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
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일

0 개 추천

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월 14일
thanx a lot.but i dont need to declare it then why it is giving error in the following:
% high weights of current project
j = [1.15,1.08,1.15,1.11,1.06,1.15,1.07,1.07,0.91,0.86,0.90,0.95,0.91,0.91,1.04];
% nominal weights of previous project
l = [1.00, 1.00 , 1.00 ,1.00, 1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00];
m = [1.05,1.12,1.2];
% float z[53]= [46,16,4,6.9,22,30,18,20,37,24,3,3.9,3.7,1.9,75,90,38,48,9.4,13,2.14,1.98,50,40,22,13,12,34,15,6.2,2.5,5.3,19.5,28,30,32,57,23,91,24,10,8.2,5.3,4.4,6.3,27,15,25,21,6.7,28,9.110];
t = 17;
% size
for i = 0:2
y = z(i)
end
% cost drivers
for k = 0 : j
x = j(k)
end
% project modes
for n = 0 : 2
a = m(n)
end
% sum of importance weights of current project
double s = a + x + y;
b = s / t;
for c = 0 : l
h = l(c)
end
% sum of importance weights of previous project
e = a + d+ y;
double f = e / t;
p = 24.5 ;
g = f * p;
% indivisual distance
d = b - g;
display (d)
error:
??? Undefined command/function 'z'.
Error in ==> f at 21
y = z(i)
sheen
sheen 2011년 5월 14일
Can i use resultant value of Fuzzy inference instead of contant 339? can i link FIS result with this m file?
Walter Roberson
Walter Roberson 2011년 5월 15일
You do not need to *declare* variables, but you still need to initialize them!
What constant 339??
If you have the Fuzzy Logic Toolbox, then Yes, you can call upon it to calculate values that will be used in this routine.
sheen
sheen 2011년 5월 15일
how to call FIS calculated answer in m file in this equation?
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?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by