matlab division help needed
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I need to perform the thinning algorithm and i am stuck in the division part
t = t - exp (u \sin (x));
i programmed this in matlab and i got an error the mldivision because the two sides are not of the same size ! i am aware both should be equal of the same size but in the algorithm i need to do this kind of division and i dont know how to get my way around it in matlab..
this is my code so far
i = 0; t = 0; u = rand (0,1); x = -pi:.1:pi; t = t - exp (u \sin (x));
while t < T u2 = rand (0,1); if u2 <= (sin(x) \ max(sin(x))) u2; end i = i+1;
end
0 comentarios
Respuesta aceptada
the cyclist
el 14 de Mzo. de 2011
It looks like you have a syntax error where you assigned a value to "u".
I'm guessing that you wanted to assign it a random value from 0 to 1, but instead you made a random array of size 0x1 (an empty array).
Instead, try
u = rand(1,1);
which will be a single, random value. Do the same with "u2" inside the loop.
After that, I think you have other errors, because I see no value assigned to T, and even if there were, it looks like your while loop will never change the condition you are checking, so it will loop infinitely. Specifically, your "if" statement inside the loop will not kick you out. You need a "break" command.
2 comentarios
the cyclist
el 15 de Mzo. de 2011
You might want to re-post your code, because I'm not really sure what you've done to try to fix it.
Also, are you aware of how to use breakpoints? You can halt the execution of your code on any line, and look at each variable to see if it is doing what you expect.
Más respuestas (2)
Sisi Ma
el 14 de Mzo. de 2011
maybe you are looking for the "dot division" (in matlab a.\b). it performs element by element division of two maxtrix.
Walter Roberson
el 10 de Abr. de 2011
I'm still uncertain that the \ operator was wanted rather than the / operator ??
0 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!