How to convert the output of this coding to txt file formate using Matlab?
Ältere Kommentare anzeigen
HI respected MatLab community members,
could anyone help how to generate text file of it.
Thanks in advance for all kind cooperation and support.
Regards,
R1 = 16; R2 = 12; R3 = 8; C1=[10 12 14]; C2=[28 18 20]; C3 = [40 24 26];
figure(1)
numPoints = 10000;
r = randn(3, numPoints);
r = bsxfun(@rdivide, r, sqrt(sum(r.^2,1)));
r = R1 * r;
x1=C1(1,1);
y1=C1(1,2);
z1=C1(1,3);
Xs1 = r(1,:) + x1 ; % Extract Xs1 from row #1.
Ys1 = r(2,:) + y1; % Extract Ys1 from row #2.
Zs1 = r(3,:) + z1; % Extract Zs1 from row #3.
% Display the shell of points
numPoints = 10000;
r = randn(3, numPoints);
r = bsxfun(@rdivide, r, sqrt(sum(r.^2,1)));
r = R2 * r;
x2 = C2(1,1);
y2 = C2(1,2);
z2 = C2(1,3);
Xs2 = r(1,:) + x2; % Extract Xs2 from row #1.
Ys2 = r(2,:) + y2; % Extract Ys2 from row #2.
Zs2 = r(3,:) + z2; % Extract Zs2 from row #3.
hold on
numPoints = 10000;
r = randn(3, numPoints);
r = bsxfun(@rdivide, r, sqrt(sum(r.^2,1)));
r = R3 * r;
x3 = C3(1,1);
y3 = C3(1,2);
z3 = C3(1,3);
Xs3 = r(1,:) + x3; % Extract x from row #1.
Ys3 = r(2,:) + y3; % Extract y from row #2.
Zs3 = r(3,:) + z3; % Extract z from row #3.
hold on
axis square;
xlabel('X', 'FontSize', 20);
ylabel('Y', 'FontSize', 20);
zlabel('Z', 'FontSize', 20);
%Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
hold off
axis square;
xlabel('X', 'FontSize', 20);
ylabel('Y', 'FontSize', 20);
zlabel('Z', 'FontSize', 20);
%Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
hold off
ix1 = (Xs1-x2).^2+(Ys1-y2).^2+(Zs1-z2).^2 < R2^2;
scatter3(Xs1(~ix1),Ys1(~ix1),Zs1(~ix1),20,'r','h','filled','MarkerFaceColor',[1 0 0])
hold on
ix2 = (Xs2-x1).^2+(Ys2-y1).^2+(Zs2-z1).^2 < R1^2;
scatter3(Xs2(~ix2),Ys2(~ix2),Zs2(~ix2),20,'r','h','filled', 'MarkerFaceColor',[1 0 0])
hold on
ix3 = (Xs3-x2).^2+(Ys3-y2).^2+(Zs3-z2).^2 < R2^2;
scatter3(Xs3(~ix3),Ys3(~ix3),Zs3(~ix3),20,'r','h','filled', 'MarkerFaceColor',[1 0 0])
hold on
ix4= (Xs2-x3).^2+(Ys2-y3).^2+(Zs2-z3).^2 < R3^2;
scatter3(Xs2(~ix4),Ys2(~ix4),Zs2(~ix4),20,'r','h','filled', 'MarkerFaceColor',[1 0 0])
5 Kommentare
dpb
am 31 Mai 2020
If it's an m-file, you already have a text file containing it...if it's from some source like the forum here that you pasted in, paste it into the MATLAB editor in a new window, name it appropriately and save it.
M.S. Khan
am 31 Mai 2020
dpb
am 31 Mai 2020
Just use copyfile to make a copy of it with some other file name. You're making this much more difficult than it is...you ALREADY HAVE A FILE that is text. If you want another copy by a different name/extension, then just make a copy of the m-file.
M.S. Khan
am 31 Mai 2020
dpb
am 31 Mai 2020
Oh. That's different Q?, indeed! OK, sorry, language sometimes gets in the way, granted. No problem, glad to help once know what the real Q? is...
You haven't saved the output to write, locally, it is in the X/Y/ZData arrays of the figure, but that's not easiest way to get at it. What you need to do is to use temporary variable(s). I'll add some code to Answer now we've got a target to shoot at...
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!