To talk on Icrontic, just register!

It only takes 30 seconds.

Have an account? Sign in:

Forgot?
kelemvor
New to the neighborhood
kelemvor
1 Posts

need help - matlab

Hi I'm writing some code for a project that I'm doing, but I'm gettinga bit stuck with a plot function - well a part of it anyway, I want to may a plot that will draw a circle/circular function. Everytime I run the following code:

plot(R_sc_E(:,1),R_sc_E(:,2))
hold on
circle([0,0],R_earth,200,'g');
title('Position with Respect to Earth')
xlabel('km')
ylabel('km')
axis equal

It tells me that I have an undefined function of variable called 'circle', if I create an m file with a routine for creating a circle

ie
format compact % tightens loose format
format long e % makes numerical output in double precision
theta = linspace(0,2*pi,100); % create vector theta
x = cos(theta); % generate x-coordinate
y = sin(theta); % generate y-coordinate
plot(x,y); % plot circle
axis('equal'); % set equal scale on axes per pixel
title('Circle of unit radius') % put title
c=2*pi % prints out 2*pi value
disp('end circle.m') % prints out literal string.
% End Circle

it then tells me that I'm trying to run a script as a function, can anyone help.

Thanks
shwaip
elaborate bot
shwaip
5,729 Posts
matlab is telling you exactly what you need to know .

functions and scripts are two different types of .m files. The main difference is that a function can take arguments, and will keep all of its variables in a separate workspace, and a script cannot take explicit arguments, and shares the main workspace.

by calling circle([0,0],R_earth,200,'g');, matlab is interpreting this as calling the circle function with those arguments, however, you've written circle.m as a script - it doesn't need any arguments to plot the earth circle.

you'd either need to rewrite circle.m as a function, or to call it as if it's a script.
__________________ my photostream for ic photography challenge

Anyone who wants dropbox, please use my referral link
Similar Threads
Thread Thread Starter Forum Replies Last Post
matlab mex function? loga Matlab Help 0 12 Feb 2008 2:56pm
matlab solver - grid search Dina Matlab Help 8 6 Jun 2007 5:29pm

Go Back   Icrontic Forums > Tech: Software > General Software > Matlab Help
Jump to
This Thread Search this Thread
Search this Thread:

Advanced Search


Current time: 8:53am (GMT)
Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Get Vanilla instead. Trust me.