matrix addition is problemtic in finding similaity between projects
Ältere Kommentare anzeigen
[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 Kommentare
Oleg Komarov
am 23 Mai 2011
http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
Matt Fig
am 23 Mai 2011
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...
shimli
am 25 Mai 2011
Antworten (3)
Sean de Wolski
am 23 Mai 2011
0 Stimmen
Put a break point on line 36 and investigate the sizes of the matrices.
3 Kommentare
shimli
am 23 Mai 2011
Sean de Wolski
am 23 Mai 2011
Click on the little black dash on the edge of the line in the editor.
shimli
am 23 Mai 2011
Matt Fig
am 23 Mai 2011
0 Stimmen
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 Kommentare
shimli
am 23 Mai 2011
shimli
am 23 Mai 2011
Matt Fig
am 23 Mai 2011
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.
Matt Fig
am 23 Mai 2011
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.
shimli
am 23 Mai 2011
Matt Fig
am 23 Mai 2011
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.
shimli
am 23 Mai 2011
shimli
am 23 Mai 2011
Walter Roberson
am 23 Mai 2011
0 Stimmen
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 Kommentare
shimli
am 23 Mai 2011
shimli
am 23 Mai 2011
Walter Roberson
am 23 Mai 2011
I think I need it in the more mathematical form, sorry.
shimli
am 25 Mai 2011
Walter Roberson
am 25 Mai 2011
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.
Walter Roberson
am 25 Mai 2011
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
shimli
am 25 Mai 2011
Walter Roberson
am 25 Mai 2011
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.
shimli
am 27 Mai 2011
Walter Roberson
am 27 Mai 2011
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.
shimli
am 27 Mai 2011
Walter Roberson
am 27 Mai 2011
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).
shimli
am 28 Mai 2011
shimli
am 28 Mai 2011
shimli
am 30 Mai 2011
Oleg Komarov
am 30 Mai 2011
imaginary part of the complex number
shimli
am 2 Jun. 2011
Sean de Wolski
am 2 Jun. 2011
real()
shimli
am 4 Jun. 2011
Matt Fig
am 4 Jun. 2011
x = complex([2.33,4.123],[45.5,66.7])
real(x)
imag(x)
Kategorien
Mehr zu Cell Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!