How dealing the instruction solve with a loop
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Good morning to everybody.
I posted a question yesterday and I figured out how to fix the errors in my code. As usual sorry for my english and for my bad skills in Matlab but I am quite new at it.
I am writing you again to ask for another help regarding the use of the instruction "solve" to find the solutions of 2 equations contening parameters that are not fixed but change values according to the loop at the beginning of my code. More into details this is the code I am using:
load data_4d;
for j=1:5
for i=1:6
k=data_4d{1,j}{1,i}.frame;
wristx(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,10);
wristxv=wristx(i,j,k);
wristy(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,11);
wristyv=wristy(i,j,k);
wristz(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,12);
wristzv=wristz(i,j,k);
objupx(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,76);
objupy(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,77);
objupz(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,78);
objdownx(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,79);
objdowny(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,80);
objdownz(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,81);
objcenterx(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,82);
objcentery(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,83);
objcenterz(i,j,k)=data_4d{1,j}{1,i}.marker_positions(k,84);
cx(i,j,k)=(objupx(i,j,k)+objdownx(i,j,k))./2;
cxv=cx(i,j,k);
cy(i,j,k)=(objupy(i,j,k)+objdowny(i,j,k))./2;
cyv=cy(i,j,k);
cz(i,j,k)=(objupz(i,j,k)+objdownz(i,j,k))./2;
czv=cz(i,j,k);
m(i,j,k)=(cy(i,j,k)-wristy(i,j,k))./(cx(i,j,k)-wristx(i,j,k));ù mv=m(i,j,k);
[x,y]=solve('(x-cxv)^2+(y-cyv)^2=20^2','(y-cyv)-mv*(x-cxv)=0');
end
end
The solutions I got are: x =
(cxv*mv + 20*mv*(1/(mv^2 + 1))^(1/2))/mv
(cxv*mv - 20*mv*(1/(mv^2 + 1))^(1/2))/mv
and y=
cyv + 20*mv*(1/(mv^2 + 1))^(1/2)
cyv - 20*mv*(1/(mv^2 + 1))^(1/2)
The problem is that I used support variables to allow the instruction "solve2 to work.
My definitive question is:How can I have numerical solutions for the different values of the indeces?
I kindly thank everyone who is giving me a help.
Best Regards
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!