1

The Following is the basic skeleton for my MATLAB program. Each box is a class definition.

Scroll down for the error. alt text Note: 1. Each Class has a custom constructor


The Error

Undefined function or variable 'Troom'.

Error in ==> wall>wall.wall at 31
        function o = wall(Tr)

Error in ==> mainfile at 5
        w1 = wall();

This comes when I create an object of Class wall from another file "mainfile"


Question

  1. Why is this happening?
  2. Am I getting wrong in the concepts of OOP for Matlab specific?
  3. How do I resolve this?

Thanks in Advance!


PS: Code

function o = wall()
        Tr = o.Troom*2;
        o.N = round(1/o.dx) + 1;
        o.T = Tr * ones(o.N,1);
        o.Tinf = Tr;
        o.update_properties();
    end

Code 2

classdef wall
properties
    dx = 0.01;
    dt = 0.4;
    L = 0.16;
    N;
    tlimit = 1505.2;
    sbc = 5.670400e-8 % The Stefan-Boltzmann Constant

    a;
    hi; % Surface Conductivity of Inner Surface
    bi;
    ho; % Surface Conductivity of Outer Surface
    bo;
    lamb;

    Troom = 298; % Room Temperature (K)
    Tinf;
    T;

    room = compartment();
    conc = concrete();
    fire = fireProperties(Troom);

end
4
  • Actual code would be helpful, it's impossible to say what's happening from what you've given us. Commented May 24, 2010 at 13:21
  • I have put the constructor code, where the problem is occurring. :) Hope it helps. The other classes have long code that would perhaps be irrelevant here. Commented May 24, 2010 at 13:28
  • I am myself confused as to why this is happening. coz. It is not showing so for other variables. Commented May 24, 2010 at 13:30
  • It might also help to see the class's properties block. Commented May 24, 2010 at 13:31

1 Answer 1

2
room = compartment();
conc = concrete();
fire = fireProperties(Troom);

Yeah, there's your problem right there. Troom can't be used in the context of the properties block. Either put the constant in for Troom or move these into the constructor where they belong.

Sign up to request clarification or add additional context in comments.

3 Comments

Done! Great! Thanks a lot! One more question: The OOP docs on Mathworks seem long winded and confusing. Is there a better treatment for matlab OOP than on mathworks?
You should at least consider using Python+numpy+scipy if you are going to do OOP for scientific computing. Python is much better suited for OOP than Matlab, IMO.
kk. will look into that. Thnx! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.