Making a Function with output only, no input

조회 수: 61 (최근 30일)
Ahmad Mushtaq
Ahmad Mushtaq 2019년 11월 8일
답변: KSSV 2019년 11월 8일
Need to start by hardcoding the test data into two 1D arrays. X's are 1, 2, and 3 and y's are 4, 5, and 8. The input parameters to the function will be void (that is, no input) and the output will be the two arrays defined in the function. Once you program works, I can then substitute the experimental data. Therefore, I want the size of the pre-allocated arrays to be as large as the largest set of data I expect to have.
  댓글 수: 2
dpb
dpb 2019년 11월 8일
Matlab allocates on assignment...the arrays will be whatever size you create them as. There's really no point in a function here at all...just put the data into a file and read it. But, the form of the function would be
function [x,y]=returnxy()
x=[...]; % your data here
y=[...]; % your data here
end
Ahmad Mushtaq
Ahmad Mushtaq 2019년 11월 8일
So this is what I did before even and I only get the one array output.
getData1.jpg

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

채택된 답변

KSSV
KSSV 2019년 11월 8일
Run / call the function by typing as below in the command window.
[x,y] = getData() ;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by