DNdog =
7
11
BNdog =
4
4
blnmynokta =
11
for i = 1:length(DNdog)
for j = 1:(length(blnmynokta))
if (BNdog(i) == blnmynokta(j))
A(i,j) = [1];
elseif (DNdog(i) == blnmynokta(j))
A(i,j) = [-1];
end
end
end
A =
0
-1 % This matrix is formed.
The matrix that should occur is;

2 comentarios

Jan
Jan el 26 de Abr. de 2017
What exactly is your question?
Muhendisleksi
Muhendisleksi el 26 de Abr. de 2017
A =
0 0 0
0 0 0
0 0 0
-1 0 0
0 -1 0
0 0 -1
I have to get this result. But I could not.

Iniciar sesión para comentar.

 Respuesta aceptada

Stephen23
Stephen23 el 26 de Abr. de 2017
Editada: Stephen23 el 26 de Abr. de 2017

0 votos

This is simple with toeplitz:
>> nC = 3;
>> nR = 6;
>> vC = zeros(1,nC);
>> vR = zeros(1,nR);
>> vR(end-nC+1) = -1;
>> toeplitz(vR,vC)
ans =
0 0 0
0 0 0
0 0 0
-1 0 0
0 -1 0
0 0 -1

3 comentarios

Andrei Bobrov
Andrei Bobrov el 26 de Abr. de 2017
A = zeros(nR,nC);
A(nC+1:nR+1:end) = -1;
Muhendisleksi
Muhendisleksi el 5 de Mayo de 2017
nC = 6;
nR = 6;
If nC and nR take these values;
A =
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
-1 0 0 1 0 0
0 -1 0 0 1 0
0 0 -1 0 0 1 %How can I get this value?
Stephen23
Stephen23 el 5 de Mayo de 2017
@Muhendisleksi: you can solve this yourself quite easily. One way would be to use zeros and toeplitz and concatenate the outputs on top of each other. When you actually read the documentation and try some examples then you will learn how to use MATLAB and you will learn how to solve problems yourself. Start by reading the docs for the two functions that I told you, and experimenting with them.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 26 de Abr. de 2017

Comentada:

el 5 de Mayo de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by