matrix addition is problemtic in finding similaity between projects

[EDIT: Mon May 23 17:44:47 UTC 2011 - Reformat - MKF]
[EDIT: 200110523 12:48 CDT - merge comment - WDR]
% 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];
% 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
% weights
for j = 1:15
x{j} = 1:j ;
end
% 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;
%weights 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};
plz help how to handle it?
plz tell how to put break point to check size of metrix?

3 Comments

http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
shimli,
To format your code, you would simply edit your original post (do not make a comment!) and highlight only the portion of your post which is MATLAB code - then hit the button that looks like this:
{} Code
I have already done this for you, but next time you will know how...
thanx a lot for guidance. plz help me to overcome this error.

Sign in to comment.

Answers (3)

Put a break point on line 36 and investigate the sizes of the matrices.

3 Comments

Click on the little black dash on the edge of the line in the editor.
i have set break point before line 38 that is b = s/T ; but it didnt show size of metrix..........??

Sign in to comment.

You are trying to add arrays with different sizes.
  • a{m} is 1-by-3
  • x{j} is 1-by-15
  • y{z} is 1-by-3
You must have made a miscalculation prior to the line somewhere, or a logical error.

8 Comments

how to add this data?
please help.which structure is suitable? if not array or matrix.
is declaration of arrays is correct in my code??
You cannot add a 1-by-3 to a 1-by-15. How would you propose to do this?
You need to stop and think about what you are doing for a minute, then (AFTER thinking about what you are trying to do) go through your code line-by-line to examine it and see if it is doing what you need to do.
I am going to make a guess here. Part of the problem may be that you have variables named j,l,m and z. In your 4 FOR loops, you use a loop variable named j,l,m and z. Did you really mean to do something different with those loops than fill your cell arrays with numbers 1 through (loop variable)? You are also using these same names for indexing into the cell arrays...
I think you may need to be much more careful in the way you are writing code!
Let us know if this is part of the problem, and what you are actually trying to do.
i have created loops becoz i have three modes and i have to use each of them one by one .same is the case with other loops.
Notice, shimli, that I did not question your need of loops. What I was saying is that you used a loop variable with the same name the other variables you defined earlier. This may not be what you want to do. Paste this example and see what I mean:
K = 355/113 % A constant needed later.
for K = 1:5,end % A loop with loop variable overwriting K...
K % Display the value of K after the loop - old value is lost.
yes u r right . i shuold remove the following from my code
%cost drivers of previous project
for l = 1:2
h{l} = 1 :l;
end
becoz modes are already declared
% project modes
for m = 1 :3
a{m} = 1:m;
end
same modes and cost drivers are used for both projects.
for l = 1:15
h{l} = 1 :l;
end
it should be like that.

Sign in to comment.

Sorry, there is still no point in trying to debug your code without the pseudocode. I did create a list of places you could upload that too (as your previous attempt included symbols that could not be read), but you might perhaps not have seen it as your question went corrupt (which I have brought to the attention of Mathworks). The list of places you can upload is here: http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers

20 Comments

thanx . i have faced problem due to going wrong with my question and at last i created my account again.well i have posted formula last time.have you seen it?
due to some problem in my system i couldnt send pseudo code right now but formula is:
sum of attributes of one project divided by total sum of cost drivers minus sum of attibutes of other project which is muliplied by p = 24.5.
attributes are size, mode and cost drivers.
plz answer soon.
I think I need it in the more mathematical form, sorry.
http://www.speedyshare.com/files/28640821/form.wmf
plz check the above link for mathematical form.reply soon.
I do not use Windows. Please upload a standard image format instead of Windows MetaFile.
Also, the service you have chosen uses tracking cookies, which is not appreciated. A different service would be preferred.
Please see the updated list of upload sites, http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
http://www.easy-share.com/1915667995/form.jpg
check it.rpl soon.
Well that was a nuisance to download, but I have the image now.
I also have to do something else for the next bit of time.
hello walter!
have to find any solution of my problem? plz help me and tell me how to do with it??
Sorry I have not had a chance to look at that, and likely will not have a chance today. There was no obvious correspondence between your code and the equations, so I will need to study both to figure out what your strategy is.
i have brought some changes in my code.
t = 17;
a =0;
b=0;
%size
effort = 12;
effort1=14;
if ((z=46) & (j=1.15))
a = effort;
end;
% project modes
h=1;
% sum of importance weights of current project
s = z + j ;
b = s / t;
if ((z1=50) & (j1=1.15))
b = effort1;
end;
% sum of weights of previous project
e = z 1+ j 1+ h1 ;
f = e / t;
p = 24.5 ;
g = f * p;
% distance
d = b - g;
disp(d)
i think i dont need for loops instead i haved used if else which is more appropriate to find distance between two software projects.plz see the code .and it gives following error:
??? Error: File: I:\MCS\MSc\matlabinstalled\work\efffff.m Line: 9 Column: 7
The expression to the left of the equals sign is not a valid target for an assignment.
plz help me.i have changed my code accoring to requirements but still it is giving problem.
walter ! what is your field of study?
In your "if" statements, change the "=" to "=="
My field of study was "computer mathematics" -- a mix of computing theory, theoretical mathematics, applied mathematics, and science (chemistry and physics).
yes i have changed it it is giving value in negative . i need value between 0 and 1.what should i do????? i have changed h1= 1.002, h =1.003 but still it is problematic.plz help.
-1.4452 + 0.0588i this is resultant value. i dont know what is i??
hellooooooooo
can anyone reply my problem?
-1.4452 + 0.0588i
what is " i" in resultant value of above code?
imaginary part of the complex number
how i get rid of this imaginary part?
x = complex([2.33,4.123],[45.5,66.7])
real(x)
imag(x)

Sign in to comment.

Categories

Asked:

on 23 May 2011

Community Treasure Hunt

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

Start Hunting!