How can I add third column to matrix and plot?

1 Ansicht (letzte 30 Tage)
Ender Rencuzogullari
Ender Rencuzogullari am 23 Dez. 2015
Dear Contributers,
There is loop;
X and Y are row vectors and their size depend on inputs. By the way, the iteration number n and the size of X and Y can be different. As I said, they depend on inputs.
for i=1:n
X_troc_rotate= X.*cos(i*rotation_increment) - Y.*sin(i*rotation_increment);
X_troc_rotateh= X_troc_rotate./cos(deg2rad(helix_angle));
Y_troc_rotate= X.*sin(i*rotation_increment) + Y.*cos(i*rotation_increment);
Helix_Troc = [X_troc_rotateh(1:K1) ; Y_troc_rotate(1:K1)];
fileID = fopen('helix_trochoid.txt','a');
fprintf(fileID,'%f %f\n ', Helix_Troc);
fclose(fileID);
plot(X_troc_rotateh(1:K1), Y_troc_rotate(1:K1),'-r','LineWidth',2)
end
I want to add third axis which is Z into Helix_Troc to get the text file with 3 columns.
Z = face_width / n ;
the coordinates of X_troc_rotateh and Y_troc_rotate have only one Z value for every iteration
%for first iteration (i=1);
X_rotateh(1) Y_rotate(1) Z*i
X_rotateh(2) Y_rotate(2) Z*i
.
.
X_rotateh(K1) Y_rotate(K1) Z*i
%for second iteration (i=2);
X_rotateh(1) Y_rotate(1) Z*i
X_rotateh(2) Y_rotate(2) Z*i
.
.
X_rotateh(K1) Y_rotate(K1) Z*i
%so on..
My second question;
I want to get 3D graph with those values. Thus, I need to plot
%for first iteration (i=1)
X_troc_rotateh(1:K1) and Y_troc_rotate(1:K1) curve on Z*i
%for second iteration (i=2)
X_troc_rotateh(1:K1) and Y_troc_rotate(1:K1) curve on Z*i
% so on..
How may I do? Thanks in advance.

Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by