How can I create a method which takes an excel file as an argument in a constructor?
이전 댓글 표시
Basically, I'm trying to construct a method that allows users to input a data file. It can be excel or ascii, and the method reads it as a matrix which can then be tested on.
Here is some of the rudimentary code I've modified from the tutorial:
classdef BankAccount < handle
properties (Hidden)
AccountStatus = 'open';
end
properties (SetAccess = private)
VEC
AccountBalance = 0;
end
events
InsufficientFunds
end
methods
function BA = BankAccount(filename, InitialBalance)
BA.VEC = xlsread(filename);
BA.AccountBalance = InitialBalance;
then I try: BankAccount('sample.xlsx',55)
I'm getting an error: No public field VEC exists for class BankAccount.
Error in BankAccount (line 20) BA.VEC = xlsread(filename);
채택된 답변
추가 답변 (1개)
Jordan Ledvina
2013년 1월 16일
0 개 추천
댓글 수: 1
Cedric
2013년 1월 16일
Great! I already had issues with '<' in other contexts after cut and paste from PDFs. If you deleted < handle and rewrote it afterwards it might be something similar that happened.. I guess you'll discover that after your next cut and paste ;-)
Cheers,
Cedric
카테고리
도움말 센터 및 File Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!