import data problem and incorrect answer

1 vue (au cours des 30 derniers jours)
Mo Das
Mo Das le 17 Mai 2019
Commenté : Mo Das le 17 Mai 2019
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 commentaires
Guillaume
Guillaume le 17 Mai 2019
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.
Mo Das
Mo Das le 17 Mai 2019
thank u so much

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by