Save data from while loop
Show older comments
How I can save x,y,z data from each irritation and build a matrix ? So I can use them for future work ...
t=0;
while t<100
v=pi/10;
r=6;
dt=0.1;
w=v/r;
t=t+dt;
theta=pi/2;
x=r*sin(theta-w*t)
y=r*cos(theta-w*t)
z=sqrt(10^2-x^2-y^2)
end
Accepted Answer
More Answers (1)
madhan ravi
on 5 Jul 2019
Edited: madhan ravi
on 5 Jul 2019
You don’t need a loop , simply define t as
t = 0:dt:100;
doc while % to know more about the loop
doc for
and use element wise operation ( https://in.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html ) meaning * to .* and ^ to .^
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!