Fixing a plotting problem over a fixed axes

I want the below spirals to be evenly spaced (in both x and y axes). I am hoping distance between the rows and columns of the helical spirals to be the same, while each center will lie on the same line. I am not sure how to use MATLAB to calculate that for me. The radius of the helical spirals will change and I think there is way to use MATLAB to evenly space them out rather than manually calculating the distance of them.
The axes will always be constrained from -255 to 255, so only radius stays the same.
I pasted the code and what the spirals look from the xy axes
I am hoping the spacing between each row would be constant so that the spirals lie on the same line
Code
clc; clear; close all
%
% prompt1 = 'Radius: ';
% radius = input(prompt1);
% prompt2 = 'Layer Height: ';
% height = input(prompt2);
height = 250;
% prompt3 = 'Number of Layers: ';
% numlayer = input(prompt3);
spirals = (1:10:61);
num = 1:1:7;
for columns=1:4
for rows = 1:length(spirals)
center = -250 + (spirals(rows))*num(rows); % this was calculated to work only for this radius
indent =255 - (columns*30);
gap=height./columns;
d=height;
r = spirals(rows);
z=linspace(0,d,1000);
t=(2*pi/gap)*z;
x=r*cos(t)+center;
y=r*sin(t)+ indent;
hold on
plot3(x,y,z,'o','MarkerSize',2)
xlim([-255 255])
ylim([-255 255])
zlim([1 255])
grid on
xlabel('\it Increasing Radius \rightarrow')
ylabel('\it Increasing Layer Height \leftarrow')
end
end

7 Comments

How then should the axes of circles be located?
11Untitled.png
the centers of the spirals belonging to each row should coincede, I hope that answers the question. The first and the last of the largest spirals should be touching the axes.
Can make a simple drawing?
I had to make a sketch. The center lines (drawn for reference) should have even spacing and all the centers of the spirals should fall on the centerlines.
Hope this helps, thanks in advance. Really appreciate the help
WhatsApp Image 2019-08-19 at 3.29.03 PM.jpeg
Currently, my plot has overlapping of the spirals. The goal is to get rid of that overlapping. I want to know how I can make MATLAB understand the necessarcy distance so that there is no overlap between rows.
The reason I want MATLAB to solve fit the spirals on the axes, rather than manually calculating the required distance, is because I intend to change the radius of each spiral on each row later. I do not wish to recalculate the distance again
What if radius of spirals too big for
ylim([-255 255])
the radius for the spirals being picked will adhere to the limit. My problem is getting rid of the overlap of the spirals. Please let me know how I could do it.

Sign in to comment.

 Accepted Answer

See attached file
121Untitled.png
dy = max(spirals);
indent = linspace(-255+dy, 255-dy,4);
y=r*sin(t)+ indent(columns);
FOr thicker line use:
plot(x,y,'linewidth',2)

More Answers (0)

Asked:

on 19 Aug 2019

Answered:

on 19 Aug 2019

Community Treasure Hunt

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

Start Hunting!