how to write a function checking to see if a file is in a format of a 2 row matrix, and then creating separate arrays for each row
2 views (last 30 days)
Show older comments
I want a function to be able to do the following: Load the .dat file. Then call a function that checks if the file is in the format of a 2 row matrix. If so, the function places the two rows in two arrays name X and Y, and returns the two arrays to the menu1 script; otherwise, it halts the entire program. I've tried various methods to get the data into this form but to no avail.
0 Comments
Answers (2)
Sean de Wolski
on 20 Dec 2011
if size(A,1)==2;
X = A(1,:);
Y = A(2,:);
else
error('Fail!');
end
0 Comments
Walter Roberson
on 20 Dec 2011
assert(size(A,1)==2, 'Oh no! Program needed a matrix with two rows!')
X = A(1,:);
Y = A(2,:);
0 Comments
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!