이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
datatypes
조회 수: 12 (최근 30일)
이전 댓글 표시
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
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
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
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
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
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.
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
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.
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
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
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
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
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.
Walter Roberson
2011년 5월 21일
*Any* file sharing site that doesn't require us to register and log on to see the files.
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.
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
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?
추가 답변 (1개)
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
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)
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
