MATLAB: For loop number of elements

for looplengthMATLAB

Hello I have this code so far, it wont run because the number of elements of winddivergencex is not the same number of elements as n because of the differentiation, how can I get this to work? Thanks
for n = 1:length(dataind)
winddivergencex(n)= (diff(Ui(min(dataind{n}):(max(dataind{n})))))./(diff(longm(min(dataind{n}):(max(dataind{n})))));
end

Best Answer

Depending on Ui, dataind and longm, this could work:
winddivergencex(n,:)=...
or
winddivergencex(:,n)=...