Prev: Quotations
Next: loadlibrary - function not found
From: Aman on 1 Jul 2010 18:43 function s_path = KShortestLink(G,k,u,v) NoN = size(G,1);%no of nodes in graph NoN s_path= zeros(k,NoN); for p = 1:k [dist, path]= graphshortestpath(G, u, v); if (dist~=inf) n = size(path); s_path(p,1:n)= path; for i = 1:n-1 G(path(i),path(i+1))=0; G(path(i+1),path(i))=0; end end end ================================= clc; G = [ 0 1 1 0 ;1 0 1 1 ;1 1 0 1 ;0 1 1 0 ]; k = 2; u = input('Enter a value\n'); v = input('Enter a value\n'); G=sparse(G); s_path = KShortestLink(G,k,u,v) ========while i am running this program and calling the function KShortestLink .. This error msg shows. What does it mean and how does it will resolves? ??? Subscripted assignment dimension mismatch. Error in ==> KShortestLink at 12 s_path(p,1:n)= path; Error in ==> short_path at 7 s_path = KShortestLink(G,k,u,v)
From: us on 1 Jul 2010 18:56 "Aman " <am.amangupta(a)gmail.com> wrote in message <i0j5lo$hdi$1(a)fred.mathworks.com>... > n = size(path); > s_path(p,1:n)= path; > ??? Subscripted assignment dimension mismatch. > > Error in ==> KShortestLink at 12 > s_path(p,1:n)= path; according to the description of GRAPHSHORTESTPATH (we do not have the tbx), PATH is a ROW vec... hence, p=1:4; n=size(p) % n = 1 4 % <- #rows/#cols % thus, try n=size(p,2) % n = 4 us
From: Jan Simon on 1 Jul 2010 19:02 Dear Aman, > [dist, path]= graphshortestpath(G, u, v); > if (dist~=inf) > n = size(path); > s_path(p,1:n)= path; > ??? Subscripted assignment dimension mismatch. Set a breakpoint in the line "n = size(path)". If the debugger stops the execution in this line, process this line (either by using the correcponding button or typing DBSTEP in the command window). Now display the value of [n]: disp(n) Finally, you should understand, why the dimensions of (p, 1:n) and [path] do not match. BTW: Using "path" as name of a variable conflicts with Matlab's function called "path". It would be really worth to avoid this. Jan
|
Pages: 1 Prev: Quotations Next: loadlibrary - function not found |