For Loop with Temporary Variable

4 visualizaciones (últimos 30 días)
Tessa Aus
Tessa Aus el 15 de Feb. de 2017
Respondida: Walter Roberson el 15 de Feb. de 2017
I am trying to create a temp matrix to store data to later match and penalize and overwrite the original matrix. I am able to completely run through the code but the final penalization and overwriting of matrix Downlink{ii,2} is not happening. I think it has to do with how Matlab has temp variables compared to C. I have attached my code to show what I have done so far.
%if true
for ii=1:size(Downlink)
for jj= 1:size(endColumn2)
if (Downlink(ii,1)==(tgbidsdouble(1,jj)))
temp = {1,jj};
save temp;
for(kk = 1:size(endColumn))
if(temp == downlinkTable(kk,1))
Downlink{ii,2} = Downlink{ii,2}+ downlinkTable{kk,3};
end
end
end
end
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Feb. de 2017
You create temp as a cell array with two elements. You then compare it to something extracted from downlink table. That implies that the downlink table is a cell array of cells. If the test succeeds then you add the downlink table element to something. But addition is not defined for cell arrays. So we deduce that the element is numeric and that the test will never work because you compare a cell array to a number

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by