現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
datatypes
8 ビュー (過去 30 日間)
古いコメントを表示
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
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.
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
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.
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?
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 日
i want to calculate similarity between two projects.for which i have taken cost drivers,size and modes of those projects.
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.
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.
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?
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
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)
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
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)
