Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
comparing cells in excel then calculate for the sum
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
So I will try my best to explain this. So I need to find the sum of weight given chart,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170637/image.png)
I need Matlab go over each column (1-6) and grab valued x marked values and use it for calculation. Since I need the sum of weight, meaning W1+W2+W3....+W6 will bring the sum of the total weight. (here W1=10+13 and W2 = 10+13+8..etc) assuming that marked x can be marked differently for different cases how would I need to program this? I do have some idea that iteration has to be used but not too sure how I can grab certain xs for each column and calculate for Wi.How would I build this program by using while loop? Like i want to say While A(i) <= A(end) (here i am assuming A is a [1 2 3 4 5 6]) so it will check the case for each column. But how would command to matlab at that specific column (example 1), there are A and C and so on... please help! (the size is not always 6 it can be changed so you can't do A(i) <= 6)
Please help! (while loop demonstration would be great!)
0 Kommentare
Antworten (1)
Star Strider
am 20 Feb. 2018
I have no idea what you are starting with, since you did not post your chart in a form that we can read and use in a program.
If you can convert the chart to a matrix where it is possible to replace the ‘x’ values by 1 and the empty entries by 0, the maths are straightforward:
Cols = [1 0 1 0; 1 0 1 1; 1 1 0 1; 1 1 1 1; 1 1 0 0; 1 0 0 1]; % Create Matrix
Weight = [10; 11; 13; 8]; % Define Vector
Result = Cols * Weight
Result =
23
31
29
42
21
18
I cannot be certain that we can work with your chart if you do post it.
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!