help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help translating a Matlab programme


From: Nicholas Jankowski
Subject: Re: Need help translating a Matlab programme
Date: Mon, 21 Aug 2017 15:52:47 -0400



On Mon, Aug 21, 2017 at 1:44 PM, Evee_ipi <address@hidden> wrote:

Anyway, I am unable to fix it after quite some effort. ¿I wil be really
gratefull if you could help me. It is about an interactive PID simulator.


ok, you should provide the exact input you enter and error messages that you receive, so we can try to understand better what is happening. 

I took the code and ran the sample at the top of the function

>> abc([],[-1 -2 -3],10)
warning: the 'tf' function belongs to the control package from Octave Forge which

you have installed but not loaded.  To load the package, run 'pkg load
control' from the Octave prompt.

Please read <http://www.octave.org/missing.html> to learn how you can
contribute missing functionality.
error: 'tf' undefined near line 20 column 6
error: called from
    abc at line 20 column 5


This means you need to load the control package to access some of the functions.

>> pkg load control
>> abc([],[-1 -2 -3],10)
warning: the 'colordef' function is not yet implemented in Octave

Please read <http://www.octave.org/missing.html> to learn how you can
contribute missing functionality.
error: 'colordef' undefined near line 29 column 3
error: called from
    abc at line 29 column 3


this means that the colordef function is not yet implemented.  if you cannot implement it yourself you will need to work around this issue in your code.

looking at line 83, it's generally bad form to use == to compare strings. strcmp is preferred. == will sometimes work, but it will give an error if the comparison items aren't equal length, rather than just producing 'false'

>> foo = 'test'
>> strcmp(foo,'test')
ans = 1
>> strcmp(foo,'tesy')
ans = 0
>> strcmp(foo,'testy')
ans = 0

>> if (foo=='test'), 1, else, 0, endif
ans =  1
>> if (foo=='tesy'), 1, else, 0, endif
ans = 0
>> foo == 'testy'
error: mx_el_eq: nonconformant arguments (op1 is 1x4, op2 is 1x5)
>> if (foo=='testy'), 1, else, 0, endif
error: mx_el_eq: nonconformant arguments (op1 is 1x4, op2 is 1x5)

so, using == can sometimes result in an error when you just want 'false'

reply via email to

[Prev in Thread] Current Thread [Next in Thread]