Hi! I have a loop which gives me vectors of length=50. How can i create a loop, so it will make 5 of these vectors? This just gives me one vector on length=250. How can I make so it will be 5 vectors?

1 view (last 30 days)
{% loop over temperatures for i=1:1:5 for t = temperatures % for i=1:1:5% Step temperatur from 0 to max in steps of 0.1 [E, SE] = mcsteps(100*size*size, t, 0.0, 1.0); % non-interacting spins %[E, SE] = mcsteps(100*size*size, t, 1.0, 0.0); % interacting spins
% Gradually build a vector of mean energies and one of mean spin
% excesses.
E_mean = [E_mean mean(E)];
SE_mean = [SE_mean ; mean(SE)];
% plot state at each t in temperature vector
% figure(10)
% plotstate(t)
% end
end end

Accepted Answer

Iddo Weiner
Iddo Weiner on 20 Mar 2017
How about create a 5*50 matrix and fill it with 2 loops?
data1 = rand(5);
data2 = rand(50);
out = zeros(5,50);
for idx1 = 1:5
for idx2 = 1:50
out(idx1,idx2) = data1(idx1) * data2(idx2);
end
end
imagesc(out)

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!