Borrar filtros
Borrar filtros

How can I make this list update rather than just saving last result?

14 visualizaciones (últimos 30 días)
Mango
Mango el 25 de Jul. de 2012
Ok, I am having problems with my for loop.
I need to have my data set write out as 'outcell':
Contract1 123 456 789
Contract1 134 348 349
Contract1 972 239 129
something along those lines. However, it will only write the last row: Contract1 972 239 129
My first instinct was to take my line
outcell = [outcell, data{j}(i)];
and change it to
outcell(i) = [outcell, data{j}(i)];
However, the length of i (or j) for that matter is much too large, so then I tried outcall{i}(j)...but the main problem I think is that the number of lines never match because my number of "Contract1" is always changing, I used the variable "contracts" to find the number of "contract1" that I will have, so I need a 1:contracts somehow put in there....not really sure.
PLEASE HELP!!!
note, dlmcell is a function that simply writes a cell array to a text file. Similar to fprintf, but works better for my data because it has a combination of stuff that doesn't work with fprintf. Regardless, the writing to the text file isn't the problem, it will work fine as long as the data I am writing is complete.
%Create new variable with specified data
for i=1:length(data{1}) %Checks first column all rows
if strcmp(data{1}(i),'ContractType1 ') %Specifies type of contract
new(i) = data{1}(i);
contracts = length(new);
outcell = [];
for j = 1:length(data)
outcell = [outcell, data{j}(i)]; %Captures last row of specified data
end
dlmcell('new.txt',outcell,'delimiter',',') %Writes the new text file and adds quotes
end
end
THANK YOU SO MUCH!

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements 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