Matlab: Circle Plotting Error
I have a matlab program. In that program I do not know the function for plotting a circle. Whether it is fplot, ez plot, funplot. Can any body guide me?
clc, clear all, clf,close a = input('Give the centre X coord : '); % X coord of centre b = input('Give the centre Y coord : '); % Y coord of centre r = input('Give the radius of circle : '); % Radius of the circle to be drawn inc = input('Give the increment step for coordinate[Default:1]: '); % Use the value if isempty(inc) % of inc greater than 1 inc =1; % usually less than radius end x = 0; y = r; d= 3-2*r; while(x < y) plot(a,b,x,y,r); if d>=0 d = d +4*(x-y)+10; x = x + 1/inc; y = y - 1/inc; else d = d + 4*x +6; x = x+1/inc; end end plot(a,b,p,q,r) for i= -1:2:1 for j= -1:2:1 plot(a+i*p,b+j*q,'r.'); plot(a+i*q,b+j*p,'r.'); grid off hold on end end title('Bresenham circle') axis([a-r-1 a+r+1 b-r-1 b+r+1]) axis equal;
Replies
-
ISHAN TOPRE#-Link-Snipped-# do you know matlab?
This is bresenham's circle algorithm. -
ISHAN TOPRE#-Link-Snipped-# #-Link-Snipped-# anyone from computer science.
-
Abhishek Rawal#-Link-Snipped-# No idea on anything related to Matlab even though I am from ECE discipline. Sorry.
-
Shashank MogheIssueI have a matlab program. In that program I do not know the function for plotting a circle. Whether it is fplot, ez plot, funplot. Can any body guide me?
clc, clear all, clf,close a = input('Give the centre X coord : '); % X coord of centre b = input('Give the centre Y coord : '); % Y coord of centre r = input('Give the radius of circle : '); % Radius of the circle to be drawn inc = input('Give the increment step for coordinate[Default:1]: '); % Use the value if isempty(inc) % of inc greater than 1 inc =1; % usually less than radius end x = 0; y = r; d= 3-2*r; while(x < y) plot(a,b,x,y,r); if d>=0 d = d +4*(x-y)+10; x = x + 1/inc; y = y - 1/inc; else d = d + 4*x +6; x = x+1/inc; end end plot(a,b,p,q,r) for i= -1:2:1 for j= -1:2:1 plot(a+i*p,b+j*q,'r.'); plot(a+i*q,b+j*p,'r.'); grid off hold on end end title('Bresenham circle') axis([a-r-1 a+r+1 b-r-1 b+r+1]) axis equal;
What exactly do you want to accomplish? Do you want a readymade fn() or do you want to use the algorithm?
Are you saying the algorithm code does not plot what you want it to plot? -
ISHAN TOPREI wanted a function to be used instead of "funplot". Apparently the problem was solved.
-
Shashank MogheIssueI wanted a function to be used instead of "funplot". Apparently the problem was solved.
What did you use instead of plot()? You can also do one easy trick in such cases, in case you are not sure of which plotting fn() to use: Go to the variables window, select the variables you want to plot, and on the top of that sub-window, there is a plot "tool", more like a drop down, which gives you a complete idea about all the possible plots you can get. -
ISHAN TOPREI used funplot only. There was an error with variables defined.
-
Shashank MogheOn a side note, I am surprised how little Engineers use Matlab 😔 It is by far Computational Science's best tool ever!
You are reading an archived discussion.
Related Posts
Microsoft has officially announced the next Windows operating system and if you were expecting it to be called Windows 9, please be informed that the next Windows will be called...
does pre-process deduplication worths now-a-day??
am doing my final project in this technology, kindly give some idea to proceed with it.
Quote:
Google’s cofounders may have downplayed that they’re interested in turning the tech giant into a healthcare company. But their company sure hasn’t been acting that way lately.
While Apple...
In my opinion, computers were mostly used for two main purposes: 'Entertainment' and 'Real Business'. Entertainment had everything - from games, movies, videos, photos to music et al. 'Real Business'...
i have read the services of os but just wanted to know when a process runs,what are the services related to it,for instance when i open my services dialoge,i saw...