Problem with calling the function
이전 댓글 표시
Task: Write a function allparts that will read in lists of part numbers for parts produced by two factories. These are contained in data files called ‘xyparts.dat’ and ‘qzparts.dat’. The function will return a vector of all parts produced, in sorted order (with no repeats). Calling the function would return the following:
>> partslist = allparts
partslist =
102 111 123 145 333 456 876 903
Here is what I get:
function outv=allparts(xyparts,qzparts)
clc
load xyparts.dat;
load qzparts.dat;
un=union(xyparts,qzparts);
disp('The result of the function:')
disp(sort(un))
end
Please, help to fix the problem!
댓글 수: 3
dpb
2014년 5월 9일
a) Your function doesn't return anything which is a requirement (the assignment doesn't say "print the results inside the function" does it?)
b) doc union includes the statement ...returns the combined values of the two vectors with no repetitions. C will be sorted.
Star Strider
2014년 5월 9일
Cristian
2014년 5월 9일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!