import data problem and incorrect answer
조회 수: 1 (최근 30일)
이전 댓글 표시
hey
i have problem with importing data to matlab
i have 2 groups of cells
A = {
[0.2 0.3 0.4 0.5]
[0 0 0.1 0.2]
[0 0 0.1 0.2]
[0 0 0.1 0.2]
[0 0 0.1 0.2]
[0 0 0.1 0.2]
[0 0 0.1 0.2]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0.8 0.9 1 1]
[0 0 0.1 0.2] }
and B = {
64960.00
380.00
270.00
480.00
360.00
120.00
540.00
253.00
998.00
1352.00
3852.00
2960.00
13562.00
650.00
1100.00 }
when i add it manually and use this loop
D = cell([15 1]);
for ii=1 : numel(A)
D{[ii]} = A{[ii]}().*B{[ii]}();
end
my answer is correct.
but when i add the first data from excel my answer is wrong . in first way i gain cell of D that the value is 15*1
and each cells have 4 items (4 *1)
but in second way i get D with 15*1 cell value but each cells have their own value . for example first one is 1*17 dubble
and second the eight one is 1* 9 !!!!
i dont know how to get my correct answer
댓글 수: 7
Guillaume
2019년 5월 17일
I've already shown you how to use matrices instead of cell arrays.
PC = cell2mat(PC); %convert cell array to matrix
BAC = cell2mat(BAC); %convert cell array to matrix
EV = PC .* BAC; %assuming you're using R2016b or later
Of course, it'd be better if PC and BAC were matrices to start with.
Not sure what you're trying to do with SigmaEV, the code you've posted makes no sense, the loops don't do anything useful. As is, it is equivalent to:
sigmaEV = EV(end, :) + EV(1, :);
Probably no what you want.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!