필터 지우기
필터 지우기

Reference to non-existent field

조회 수: 2 (최근 30일)
Arbol
Arbol 2017년 5월 27일
댓글: Arbol 2017년 5월 28일
Can someone tell me what's wrong with my classdef? When I run cool_class.funk(x) it works fine. But for cool_class.Afunction, it returns reference to non-existent field. I'm new to object, and it doesn't really make sense.
classdef cool_class
properties
tdata=[];
adata=[];
ainterp=[];
tinterp=0;
end
methods (Static)
function y = funk(x)
y=0.5*x.^2+4;
end
function output=Afunction(z)
%load shortdata.txt
%tdata= shortdata(:,1);
%adata= shortdata(:,2);
xq1=0:0.01:z;
vq1=interpn(cool_class.tdata,cool_class.adata,xq1,'linear');
output.ainterp=vq1(end);
end
end
end

답변 (1개)

Walter Roberson
Walter Roberson 2017년 5월 28일
properties belong to objects of a class, not to the class itself.
See https://www.mathworks.com/help/matlab/matlab_oop/static-data.html for information on creating data that is shared by the class.
  댓글 수: 1
Arbol
Arbol 2017년 5월 28일
Thank you for the info, I'm going to look into it! Class is the most confusing thing ever!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by