Function for creating matrix subgroups problem.
Mostra commenti meno recenti
Good day,
I am new here and also not a profesional matlab user. I am tring to help my friend with her home work. She get a task to create a function which will create matix according to given numbers, m - rows, n - columns. This is simple to do by using to for loops. The problem is that teacher at least what I understood wants to following thing. He wrote: "We divide each row into m-groups of n-numbers, further we fill up all with zeros beside the group "j" in each group row of "i"." Hard to explain. But in first group in first row should be ones. In second group of second row should be ones... etc.
Leter from m to m+n rows he want to fill all with zeros and only "n" number in each grup should be 1. Crazy task for me.
I am trying to find some solution for that by I cannot. I was trying to look for some subgoruping in matrix. But without luck.
The result shoul look like that:

What i did already is just:
function macierz = stworzMacierz(m, n)
A=[];
for i=1:m+n
for j=1:m*n
A(i,j) = i; % just temporary something
end
end
macierz = A
end
Thank You in advance with help to that matter.
I will still try to find some solution, but maybe it is something easy to be done just I don't know how to look for it.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Get Started with MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!