필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

comparing cells in excel then calculate for the sum

조회 수: 2 (최근 30일)
PetronasAMG
PetronasAMG 2018년 2월 20일
마감: MATLAB Answer Bot 2021년 8월 20일
So I will try my best to explain this. So I need to find the sum of weight given chart,
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!)

답변 (1개)

Star Strider
Star Strider 2018년 2월 20일
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.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by