matrix corresponing to the minimum value of the difference

1 view (last 30 days)
m=2
t=[1 0 0; 0 (1/sqrt(2)) (1/sqrt(2))];
v1=0.956
v2=2.4
a=[ 0 1 0];
b=[0 1 1];
p=b-a;
d1=m*a;
for x=1:1:m+1
c=d1+p*(x-1)
f=transpose(c);
vndq=t*c;
vnq=vndq(1,1)
vnd=vndq(2,1)
d(x)=abs(v2-vnq)+abs(v1-vnd)
n=min(d)
end
In the given code minimum value of d matrix corresponding c matrix
  4 Comments
Stephen23
Stephen23 on 2 Feb 2017
Edited: Stephen23 on 2 Feb 2017
@JAGADEESH JAGA: it is not the capitals in the code, but the capitals in the English that is the problem: on most forums this is considered to be "shouting", and is not very polite (do an internet search):
Communicating on an online forum is just like real life: the more polite and considerate you are, the more help you will receive.

Sign in to comment.

Answers (1)

Niels
Niels on 2 Feb 2017
DEAR CAPTAIN CAPSLOCK
CANT READ YOUR CODE. BUT PEOPLE CONTINUE USING COMMANDS WITHOUT READING THE DOCUMENTATION. TRY MIN(D(:)) OR MIN(MIN(D)). THIS WILL PROBABLY NOT WORK SINCE YOU WOULD HAVE TO DEACTIVATE CAPS LOCK
  1 Comment
Niels
Niels on 3 Feb 2017
Edited: Niels on 3 Feb 2017
About editing your question. It was all about the sentence after your code which is still unreadable since you did not use {}code. In your for loop you overwrite c 2 times. Hence c is a vector and no matrix. Preallocate c as 3x3 array
c=zeros(3,3); for i=1:m-1 c(i,:)=... end MinimumOfaMatrix=min(c(:));
Dont use x as index pls... and maybe add a question

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!