필터 지우기
필터 지우기

How to pass arguments from mfile to another function?

조회 수: 3 (최근 30일)
DhanaLakshmiR
DhanaLakshmiR 2018년 2월 20일
편집: DhanaLakshmiR 2018년 2월 20일
function [xposition yposition altitude]=position(xpos,ypos,alt,velx,vely,velz,delt)
for this function i need to pass the input arguments from another mfile how?
  댓글 수: 2
Guillaume
Guillaume 2018년 2월 20일
Can you clarify what problem you're having? The whole points of functions (m files) is that you can pass inputs and outputs between them
DhanaLakshmiR
DhanaLakshmiR 2018년 2월 20일
편집: DhanaLakshmiR 2018년 2월 20일
I have mentioned position(xpos,ypos,alt,velx,vely,velz,delt) this xpos ypos and so on have to be calculated from the program having 1000 lines of code so that i want to send that values to this function as arguments is this possible?. This function should be call back in another file

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

채택된 답변

KSSV
KSSV 2018년 2월 20일
Don't keep data in .m file......keep them in a text file, where you can use importdata / load to load the data into workspace.
If you have them in .m file....give the data a variable name..and run the file once....the variables with data will be loaded into workspace.
Or, if you have data in .m file, give them variables names as input to the function, and copy the calling function:
[xposition yposition altitude]=position(xpos,ypos,alt,velx,vely,velz,delt) ;
Under the data and run the m file.
I suggest you to keep the data in text file and use load.
  댓글 수: 3
KSSV
KSSV 2018년 2월 20일
If you have lot of for loops..you need to save your data at every iteration into a matrix....so that every value is saved. Show, us your code to get precise help.
DhanaLakshmiR
DhanaLakshmiR 2018년 2월 20일
편집: DhanaLakshmiR 2018년 2월 20일
For your convenience, i have shorted my code.
for icount =1:30000
velx=u*dcm(1,1)+v*dcm(1,2)+w*dcm(1,3);
vely=u*dcm(2,1)+v*dcm(2,2)+w*dcm(2,3);
velz=u*dcm(3,1)+v*dcm(3,2)+w*dcm(3,3);
xpos=xpos+velx*delt;
ypos=ypos+vely*delt;
alt=alt-velz*delt;
end
for 30000 iterations the values xpos ypos alt should be calculated from each minor equations available in the code,all are dependent. So that only i am asking can we pass the required datas from current mfile to the function. Kindly give answers.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by