Calling and Using function file to adjust plots

Hey, I'm sure this is quite simple, but I am getting my self confused thinking about this!I have created a script file, which will plot a 3D line plot. I have been trying to convert the line to a "tube" shape and found some code in the file share section, where the user had created their own code that allowed you to do this. My question is, how do I call their code into my script file so that it can adjust my plot. The function file is created by: Janus H. Wesenberg and is found here; http://www.mathworks.co.uk/matlabcentral/fileexchange/5562-tubeplot
Thanks

 채택된 답변

David Sanchez
David Sanchez 2013년 7월 19일

0 개 추천

Place the function m-file in the same folder of your script.
within your script, just write down the call to the function:
% your script here
...
...
% call the function
t=linspace(0,2*pi,50); % your data
tubeplot([cos(t);sin(t);0.2*(t-pi).^2],0.1);
...
% your remaining of your script follows here
...

댓글 수: 3

Mazhar
Mazhar 2013년 7월 19일
Thanks for the quick response :) Where exactly would I call the function file in my script? Would it be right in the end? or, Just before, or, just after, where I have the plot command? Also I'm confusing my self with how to call a function file in a script file.
call it when you want to plot the data. Right after the line your data is ready to be plotted. You can make a test. Write another short-easy script with some dummy data:
% dummy script/data
t=linspace(0,2*pi,50);
tubeplot([cos(t);sin(t);0.2*(t-pi).^2],0.1);
% end of dummy script
Save the previous code in a m-file next to the tubeplot m-file, in the some folder.
Run it.
It will work the same way in your original script.
Mazhar
Mazhar 2013년 7월 19일
Perfect! Got it working :D

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

nl2605
nl2605 2013년 7월 19일

0 개 추천

You can save the tubeplot function in a file named as tubeplot.m and then use it as we normally use plot functions. I hope this is what you meant to ask.

댓글 수: 3

Mazhar
Mazhar 2013년 7월 19일
I have saved the function file as tubeplot.m. Now, in my script I should change the 'plot3(.....)' to 'tubeplot([....]..)'.
right, but watch out for the input parameters. Make sure your are sending the right data.
nl2605
nl2605 2013년 7월 19일
yup! I guess you got it!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2013년 7월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by