https://uk.mathworks.com/matlabcentral/newsreader/most_recent_feed
MATLAB Central Newsreader Recent Posts
Most Recent Posts
enus
©19942017 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
https://uk.mathworks.com/images/membrane_icon.gif

Sat, 22 Jul 2017 20:29:03 +0000
Re: Find axis of rotation
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349143#955455
Ralph Schleicher
"Daniel" <daniel.thuresson@gmail.com> writes:<br>
<br>
> I have a point in space (x, y, z) with a certain orientation (rx, ry,<br>
> rz). That point moves in time to a new position and orientation (x',<br>
> y', z', rx', ry', rz') and I would like to calculate the rotation<br>
> vector for that move. I that possible with this information and how<br>
> would I do it? <br>
<br>
For a general solution (any number of dimensions and including handling<br>
of measurement errors), search for "Kabsch algorithm" and "orthogonal<br>
Procrustes problem". See <<a href="http://www.schonemann.de/Abstract1.html">http://www.schonemann.de/Abstract1.html</a>>.<br>
<br>
<br>
% alg_kabsch  Kabsch algorithm.<br>
%<br>
% [R, A, O] = alg_kabsch(Pa, Po)<br>
%<br>
% Calculate the optimal rotation matrix that minimizes the root<br>
% mean squared deviation between two paired sets of points.<br>
%<br>
% First argument PA are the point coordinates given in the<br>
% coordinate system A.<br>
% Second argument PO are the point coordinates given in the<br>
% coordinate system O.<br>
%<br>
% Arguments PA and PO are MxN matrices where M is the number of<br>
% points and N is the number of dimensions.<br>
%<br>
% Return value R is a rotation matrix describing the transition<br>
% from the coordinate system O to the coordinate system A. The<br>
% column vectors of R are the basis vectors of the coordinate<br>
% system O given in the the coordinate system A. Second return<br>
% value A is the origin of the coordinate system A given in the<br>
% coordinate system O. Third return value O is the origin of<br>
% the coordinate system O given in the coordinate system A.<br>
%<br>
% Example:<br>
%<br>
% If VO is a vector given in the coordinate system O and VA is<br>
% the same vector given in the coordinate system A, then<br>
%<br>
% va = R vo<br>
% and<br>
% vo = R' va<br>
%<br>
% are true. Likewise, if PO is a point given in the coordinate<br>
% system O and PA is the same point given in the coordinate<br>
% system A, then<br>
%<br>
% Pa = R (Po  A) = R Po + O<br>
% and<br>
% Po = R' (Pa  O) = R' Pa + A<br>
%<br>
% are true.<br>
<br>
Sorry, I can't disclose the source code since I have written it at<br>
work; but it boils down to a simple SVD as described by SchÃ¶nemann.<br>
<br>
 <br>
Ralph<br>
<br>
9010 days of Linux experience.

Sat, 22 Jul 2017 10:52:07 +0000
Read value of popup menu and pass hObject simultaneously
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349129#955454
Ahmad Towaiq
"Bruno Luong" wrote in message <oknq9o$rrt$1@newscl01ah.mathworks.com>...<br>
> "Ahmad Towaiq" <ahmad.towaiq@gmail.com> wrote in message <okngav$735$1@newscl01ah.mathworks.com>...<br>
> > "Bruno Luong" wrote in message <okl0sf$hqi$1@newscl01ah.mathworks.com>...<br>
> > > "Ahmad Towaiq" <ahmad.towaiq@gmail.com> wrote in message <okkmrr$qbj$1@newscl01ah.mathworks.com>...<br>
> > > > I have a problem reading both the value from popup menu and and hObject in my GUI program.<br>
> > > > <br>
> > > > Here is my popup menu, it is a uicontrol, not made using GUIDE:<br>
> > > > <br>
> > > > uicontrol('Style','popup','String',{'option 1','option 1'}, 'CallBack',@action);<br>
> > > > <br>
> > > ...<br>
> > > <br>
> > > > Is there a way to make the function definition of a callback coming from a uicontrol to take in more than just two arguments???<br>
> > > <br>
> > > uicontrol( ... 'Callback', @(varargin) action(varargin{:}, hObject));<br>
> > <br>
> > Bruno, thanks for the help. I still cannot figure it out though so I need you to give me a final push.<br>
> > <br>
> > I have modified my pushbuttons uicontrols as per your answer so here is what I have now:<br>
> > <br>
> > uicontrol('Style','pushbutton','Tag','first','Callback',@(varargin) action(varargin{:}, hObject));<br>
> > uicontrol('Style','pushbutton','Tag','second','Callback',@(varargin) action(varargin{:}, hObject));<br>
> > <br>
> > % When I press a button I want handles to be modified based on which button has been pressed. I want to have something like this:<br>
> > <br>
> > function action(hObject, eventdata,push_button_handle)<br>
> > % Access data in hObject<br>
> > handles = guidata(hObject);<br>
> > % Access data in the additional argument push_button_handle<br>
> > my_tag = get(push_button_handle,'Tag');<br>
> > <br>
> > if strcmp(my_tag,'first')<br>
> > handles.option = "First button was clicked";<br>
> > else<br>
> > handles.option = "Second button was clicked";<br>
> > end<br>
> > <br>
> <br>
> You seem to mix variables<br>
>  hObject the first input argument of the ACTION function is the handle of pushbutton (created by uicontrol), <br>
>  hObject declared together with the 'Callback' is whatever Object of your GUI (as I understood by the description of your first post) and it's the fourth input input argument of the ACTION function.<br>
<br>
You are absolutely right... I decided to slow down and get the basics right. I am now slowly clearing my confusion by reading carefull this article which I recommend to everyone struggling with using callbacks... Much thanks everyone.<br>
<br>
https://www.mathworks.com/help/matlab/creating_guis/sharedataamongcallbacks.html

Sat, 22 Jul 2017 08:21:08 +0000
Re: Putting axis in center of figure
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/25793#955453
kiarash
"Robin Aspey" <raspey@liv.ac.uk> wrote in message <9i9lnp$rgn$1@news.liv.ac.uk>...<br>
> I want to draw a graph in Matlab so that the 'y' axis is<br>
> in the middle of the figure with the plot symmetrical<br>
> about the y axis.<br>
> <br>
> I'm sure its easy (if you have done this already)<br>
> any suggestions would be very welcome.<br>
> <br>
> thanks in advance<br>
> <br>
> Robin Aspey<br>
> <br>
> <br>
you can use:<br>
ax = gca;<br>
ax.XAxisLocation = 'origin';<br>
ax.YAxisLocation = 'origin';<br>
<br>
which can be found in help of MATLAB 2017

Sat, 22 Jul 2017 07:05:22 +0000
Re: Find axis of rotation
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349143#955452
Daniel
"Bruno Luong" wrote in message <okupdp$me7$1@newscl01ah.mathworks.com>...<br>
> "Daniel" wrote in message <okq7u3$d0s$1@newscl01ah.mathworks.com>...<br>
> > Hi,<br>
> > <br>
> > I have a point in space (x, y, z) with a certain orientation (rx, ry, rz). That point moves in time to a new position and orientation (x', y', z', rx', ry', rz') and I would like to calculate the rotation vector for that move. I that possible with this information and how would I do it? <br>
> <br>
> <br>
> Assuming (rx,ry,rz) is the axis angle, first use Rodrigues's formula to convert to 3x3 matrix <br>
> <br>
> https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula<br>
> <br>
> Then the rotation vector w from R1 to R2 is<br>
> <br>
> L = R1 * R2.';<br>
> w = [L(3,2)L(2,3);<br>
> L(1,3)L(3,1);<br>
> L(2,1)L(1,2)];<br>
> d = L([1 5 9]);<br>
> L([1 5 9]) = dsum(d);<br>
> %w = pinv(L)*w;<br>
> w = L \ w;<br>
> <br>
> % Bruno<br>
<br>
Thanks alot! I will try this.<br>
<br>
/Daniel

Sat, 22 Jul 2017 06:57:08 +0000
Re: Find axis of rotation
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349143#955451
Daniel
"Matt J" wrote in message <oktgd7$pd4$1@newscl01ah.mathworks.com>...<br>
> "Daniel" wrote in message <okq7u3$d0s$1@newscl01ah.mathworks.com>...<br>
> > Hi,<br>
> > <br>
> > I have a point in space (x, y, z) with a certain orientation (rx, ry, rz). That point moves in time to a new position and orientation (x', y', z', rx', ry', rz') and I would like to calculate the rotation vector for that move. I that possible with this information and how would I do it? <br>
> > <br>
> > Rgds /Daniel<br>
> <br>
> <br>
> How can a "point" have an orientation? A point by definition has no size or shape, only position.<br>
<br>
You're right. Bad choice of word. Sorry for being unclear.<br>
/D

Sat, 22 Jul 2017 05:59:14 +0000
Re: Create a new matrix from a columm vector
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349131#955450
Bruno Luong
"HUGO SILVA" <hugomes@pucrio.br> wrote in message <br>
> <br>
> [Lc,Cc] = size(x); % x is the vector data<br>
> dim = fix(Lc/col); % Col is number of the column that is the number of experiments<br>
> cont=0;<br>
> <br>
> for m = 1:col <br>
> for n= 1:dim<br>
> cont=cont+1;<br>
> B(n,m)=x(cont);<br>
> end<br>
> end<br>
<br>
No preallocation for B, your code will be slow. This is equivalent to<br>
<br>
B = reshape(x(1:fix(end/col)*col),[],col);

Sat, 22 Jul 2017 05:56:09 +0000
Re: Find axis of rotation
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349143#955449
Bruno Luong
"Daniel" wrote in message <okq7u3$d0s$1@newscl01ah.mathworks.com>...<br>
> Hi,<br>
> <br>
> I have a point in space (x, y, z) with a certain orientation (rx, ry, rz). That point moves in time to a new position and orientation (x', y', z', rx', ry', rz') and I would like to calculate the rotation vector for that move. I that possible with this information and how would I do it? <br>
<br>
<br>
Assuming (rx,ry,rz) is the axis angle, first use Rodrigues's formula to convert to 3x3 matrix <br>
<br>
https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula<br>
<br>
Then the rotation vector w from R1 to R2 is<br>
<br>
L = R1 * R2.';<br>
w = [L(3,2)L(2,3);<br>
L(1,3)L(3,1);<br>
L(2,1)L(1,2)];<br>
d = L([1 5 9]);<br>
L([1 5 9]) = dsum(d);<br>
%w = pinv(L)*w;<br>
w = L \ w;<br>
<br>
% Bruno

Sat, 22 Jul 2017 03:05:45 +0000
Re: A+ guide to managing & maintaining your pc, 8th edition solutions
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/333457#955448
kbopwar@gmail.com
Can i have the answer keys? Thanks a lot

Fri, 21 Jul 2017 21:46:33 +0000
Re: Create a new matrix from a columm vector
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349131#955447
dpb
On 07/21/2017 4:12 PM, HUGO SILVA wrote:<br>
...<br>
<br>
> It worked for some cases the comand reshape, when the size of the vector<br>
> changed not divided the number of column chosen the comand did not work.<br>
...<br>
<br>
Well, no, you can't reshape N=mxn elements total into something that <br>
isn't another divisible set of factors of N.<br>
<br>


Fri, 21 Jul 2017 21:44:33 +0000
Re: Findpeaks inverted
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349157#955446
dpb
On 07/21/2017 4:02 PM, HUGO SILVA wrote:<br>
> Hello,<br>
><br>
> In my graph I have 6 peaks inverted, I need to locate in the vector only<br>
> 4 peaks. I tested the comand findpeaks but it did not work as I wished.<br>
><br>
...<br>
<br>
To find "negative peaks", use<br>
<br>
findpeaks(data,...<br>
<br>
instead to turn the valleys into peaks (and vice versa).<br>
<br>
Then you can play with all the various tunable parameters to isolate <br>
those desired from the rest...<br>
<br>


Fri, 21 Jul 2017 21:12:10 +0000
Re: Create a new matrix from a columm vector
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349131#955445
HUGO SILVA
"HUGO SILVA" wrote in message <okqr3o$no5$1@newscl01ah.mathworks.com>...<br>
> "dpb" wrote in message <oklfek$bm0$1@dontemail.me>...<br>
> > On 07/18/2017 11:43 AM, HUGO SILVA wrote:<br>
> > > Hello everyone,<br>
> > ><br>
> > > I am 5 years without work with matlab and now I am returnning work with<br>
> > > it, and for now I am little slow to find comands.<br>
> > > Here is the question.<br>
> > ><br>
> > > I have a vector A (100002x1) and I would like to create a matrix B<br>
> > > (14286 x 7).<br>
> > ...<br>
> > <br>
> > > How can I do it using the matlab?<br>
> > <br>
> > A=reshape(A,14286,7);<br>
> > <br>
> > w/ recent releases you can write it even more easily<br>
> > <br>
> > A=reshape(A,[],7);<br>
> > <br>
> > <br>
> Thank you. It worked very well. It was pretty easy to apply this comand. <br>
<br>
<br>
It worked for some cases the comand reshape, when the size of the vector changed not divided the number of column chosen the comand did not work.<br>
<br>
So I had to developed a something flexible enough to do not be limit be size of vector, here go the program I did to reshape. It is pretty simple.<br>
<br>
[Lc,Cc] = size(x); % x is the vector data<br>
dim = fix(Lc/col); % Col is number of the column that is the number of experiments<br>
cont=0;<br>
<br>
for m = 1:col <br>
for n= 1:dim<br>
cont=cont+1;<br>
B(n,m)=x(cont);<br>
end<br>
end

Fri, 21 Jul 2017 21:02:08 +0000
Findpeaks inverted
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349157#955444
HUGO SILVA
Hello,<br>
<br>
In my graph I have 6 peaks inverted, I need to locate in the vector only 4 peaks. <br>
I tested the comand findpeaks but it did not work as I wished.<br>
<br>
<br>
The diference between the first two peaks in the axis x is minor of 1700 and the second two peaks are minor 2500. <br>
<br>
The amplitude of the peaks vary between 0.6 and 0.78. The normal signal starts in 1 when the "sensor" detects something, it generated peaks under the value 1. <br>
<br>
I would like to post a picture just to show you what I am trying to say, but hope you got it.<br>
<br>
Regards<br>

Fri, 21 Jul 2017 18:41:07 +0000
Re: Can someone explain me tick2ret vs price2ret
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/322745#955441
Francesc Naya
"CharlesAntoine" wrote in message <k1dn04$96h$1@newscl01ah.mathworks.com>...<br>
> Both convert prices to returns but I o not have the same results. I could not find a good explanation about the difference between both<br>
<br>
<br>
Hi, <br>
<br>
It is true that by default tick2ret computes simple returns and price2ret uses continuously compounded returns. You can however specify the method ('Simple' in tick2ret is called 'Periodic' in price2ret).<br>
<br>
If you specified the "Ticktimes" you still get different results because price2ret normalizes the returns by the length of the time interval, while tick2ret does not:<br>
<br>
For instance using log returns, for price2ret:<br>
<br>
RetSeries(i) = log [TickSeries(i+1)/TickSeries(i)]/RetIntervals(i) <br>
<br>
while for tick2ret....<br>
<br>
RetSeries(i) = log[TickSeries(i+1)/TickSeries(i)]<br>
<br>
The same happens if you use simple returns.<br>
<br>
Francesc

Fri, 21 Jul 2017 18:16:07 +0000
Re: Find axis of rotation
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349143#955440
Matt J
"Daniel" wrote in message <okq7u3$d0s$1@newscl01ah.mathworks.com>...<br>
> Hi,<br>
> <br>
> I have a point in space (x, y, z) with a certain orientation (rx, ry, rz). That point moves in time to a new position and orientation (x', y', z', rx', ry', rz') and I would like to calculate the rotation vector for that move. I that possible with this information and how would I do it? <br>
> <br>
> Rgds /Daniel<br>
<br>
<br>
How can a "point" have an orientation? A point by definition has no size or shape, only position.

Fri, 21 Jul 2017 17:25:10 +0000
Re: Warning: Size inputs must be scalar. This will error in a future release.
https://uk.mathworks.com/matlabcentral/newsreader/view_thread/349152#955439
Gonzalo Lerner
"Bruno Luong" wrote in message <oksphv$747$1@newscl01ah.mathworks.com>...<br>
> "Gonzalo Lerner" wrote in message <okscan$8rv$1@newscl01ah.mathworks.com>...<br>
> <br>
> > <br>
> > Here's the line:<br>
> > <br>
> > outs_fit_A1=isnan(zeros(size(A1(:,suj)),1));<br>
> > <br>
> <br>
> Not sure what is the purpose of ",1" argument, just remove it:<br>
> <br>
> outs_fit_A1=isnan(zeros(size(A1(:,suj))));<br>
<br>
Thanks for the reply Bruno! That 1 was actually redundant since the size was always gonna be one column. And taking it out actually solved the warning message.