Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Undefined operator '-' for input arguments of type 'cell'.

1 visualizzazione (ultimi 30 giorni)
mayur sonawale
mayur sonawale il 4 Nov 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
for(i=1:size(Ftrain,1))
dist(1,:)=sum(abs(Ftrain(1,:) - Ftest));
end

Risposte (1)

Image Analyst
Image Analyst il 4 Nov 2018
Modificato: Image Analyst il 5 Nov 2018
You can't subtract cells. You can subtract the contents of cell if they are numeric. So you need to use braces. See the FAQ: https://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
Try it this way:
for(i=1:size(Ftrain,1))
dist(1,:)=sum(abs(Ftrain{i,:} - Ftest));
end
Ftest must be of the same type as the contents of the cell, e.g. both doubles.
  3 Commenti
mayur sonawale
mayur sonawale il 5 Nov 2018
my Ftrain is 5*2cell and Ftest is like [105.2527,42.8721]
Image Analyst
Image Analyst il 5 Nov 2018
Modificato: Image Analyst il 5 Nov 2018
But what's IN the cell? Inside each cell should also be a 1-by-2 vector. and you need to specify both row and column. Like this
thisCellsContents = Ftrain{i, someColumnNumber}
dist(i,someColumnNumber=sum(abs(thisCellsContents - Ftest));
Perhaps you need another inner loop over column.
Attach Ftrain and Ftest in a .mat file if you still need more help so I don't waste time guessing.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by