I have a question about how can I construct a loop. I have a double array and I want to code that process.
This is the array where I want to apply the process and the length is 4x4 (I'm doing only the first, but the original was 4x4x3).
b1= (:,:,1);
I want to apply for every value this process:
1.- Create a vector every time, with the information of every value of the array.
ma= 0;
for p=(136:136)
ma(p)=b1(1,1,1);
end
for p=(312:2151)
ma(p)=0
end
ma= ma';
Then, I have to do with the last result the following process (I've defined the variables before). spout1_a= spb1y.ma; spout1_b= spout1_a./spsum_pesos1; spout1_c= sum(spout1_b);
The problem is I know how can to do it for one value (the first one), but not with all of them. How can I do it?
Greetings and thank you so much,
Emma
EDIT
b1= Refl(:,:,1);
load sp1.txt;
spb1y= sp1(:,1);
spsum_pesos1= sum(spb1y);
output = cell(length(banda1), 5); % this works well
for i = 1:numel(b1)
ma = zeros(2151,1);
ma(136) = output(i);
spout1_a= spb1y.*ma;
spout1_b= spout1_a./spsum_pesos1;
spout1_c= sum(spout1_b); % I want to save that result on every value of the matrix
end
Am I writing this last part well?
forloop from 136 to 136? It's just one iteration... or perhaps you're trying to achieve something else?