Mataveid with Octave
rstflo opened this issue · comments
I have just tried to execute the RLS example under Octave 5.2.0. I get the following error:
Attribute "sampleTime" is not known in Octave transfer function object. When I code Gd.tsam = sampleTime in rls.m the next error occurs.
To me it seems like the code is not really usable with Octave although the first sentence in the description suggests so...
I have just tried to execute the RLS example under Octave 5.2.0. I get the following error:
Attribute "sampleTime" is not known in Octave transfer function object. When I code Gd.tsam = sampleTime in rls.m the next error occurs.
To me it seems like the code is not really usable with Octave although the first sentence in the description suggests so...
Hi! Can you post your code?
Here is the code I used. It is just one of the examples.
% Load data
X = csvread('.../HangingLoad.csv');
t = X(:, 1); % Time
r = X(:, 2); % Reference
y = X(:, 3); % Output position
u = X(:, 4); % Input signal from P-controller with gain 3
sampleTime = 0.02;
% Do identification of the first data set
l = length(r) + 2000; % This is half data
% Do identification on up and down
sysd_up = rls(r(1:l/2), y(1:l/2), 1, 1, 1, sampleTime);
sysd_down = rls(r(l/2+1:end), y(l/2+1:end), 1, 1, 1, sampleTime);
% Simulate
[,,x] = lsim(sysd_up, r'(1:l/2), t'(1:l/2));
hold on
lsim(sysd_down, r'(l/2+1:end), t'(l/2+1:end), x(:, end));
hold on
plot(t, y);
legend('Up model', 'Down model', 'Measured');
title('Hanging load - Hydraulic system')
xlabel('Time [s]')
ylabel('Position');
Another problem occurs when I use the OKID example.
Code:
% Load the data
X = csvread('.../MultivariableCylinders.csv');
t = X(:, 1);
r0 = X(:, 2);
r1 = X(:, 3);
y0 = X(:, 4);
y1 = X(:, 5);
sampleTime = 0.1;
% Create the model
inputs = [r0';r1'];
states = [y0';y1'];
derivatives = (states(:, 2:end) - states(:, 1:end-1))/sampleTime;
states = states(:, 1:end-1);
inputs = inputs(:, 1:end-1);
t = t'(1, 1:end-1);
[sysd, K] = okid(inputs, states, derivatives', t, sampleTime);
% Do simulation
[outputs, T, x] = lsim(sysd ,inputs, t);
close
plot(T, outputs(1, :), t, states(1, :))
title('Cylinder 0');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);
figure
plot(T, outputs(2, :), t, states(2, :))
title('Cylinder 1');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);
Another problem occurs when I use the OKID example.
Code:
% Load the data
X = csvread('.../MultivariableCylinders.csv');
t = X(:, 1);
r0 = X(:, 2);
r1 = X(:, 3);
y0 = X(:, 4);
y1 = X(:, 5);
sampleTime = 0.1;% Create the model
inputs = [r0';r1'];
states = [y0';y1'];
derivatives = (states(:, 2:end) - states(:, 1:end-1))/sampleTime;
states = states(:, 1:end-1);
inputs = inputs(:, 1:end-1);
t = t'(1, 1:end-1);
[sysd, K] = okid(inputs, states, derivatives', t, sampleTime);% Do simulation
[outputs, T, x] = lsim(sysd ,inputs, t);
close
plot(T, outputs(1, :), t, states(1, :))
title('Cylinder 0');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);
figure
plot(T, outputs(2, :), t, states(2, :))
title('Cylinder 1');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);
Try writing 'updatemataveid' in gnu octave terminal.
This code example works to 100%. No errors or warnings.
Here is the code I used. It is just one of the examples.
% Load data
X = csvread('.../HangingLoad.csv');
t = X(:, 1); % Time
r = X(:, 2); % Reference
y = X(:, 3); % Output position
u = X(:, 4); % Input signal from P-controller with gain 3
sampleTime = 0.02;% Do identification of the first data set
l = length(r) + 2000; % This is half data% Do identification on up and down
sysd_up = rls(r(1:l/2), y(1:l/2), 1, 1, 1, sampleTime);
sysd_down = rls(r(l/2+1:end), y(l/2+1:end), 1, 1, 1, sampleTime);% Simulate
[,,x] = lsim(sysd_up, r'(1:l/2), t'(1:l/2));
hold on
lsim(sysd_down, r'(l/2+1:end), t'(l/2+1:end), x(:, end));
hold on
plot(t, y);
legend('Up model', 'Down model', 'Measured');
title('Hanging load - Hydraulic system')
xlabel('Time [s]')
ylabel('Position');
Change
[,,x] = lsim(sysd_up, r'(1:l/2), t'(1:l/2));
to
[~,~,x] = lsim(sysd_up, r'(1:l/2), t'(1:l/2));
Also 'updatemataveid' in Gnu octave terminal, or MATLAB terminal. This code example works to 100%. No errors.
I alread use
[~,~,x] = lsim(sysd_up, r'(1:l/2), t'(1:l/2));
During copy/paste the ~ was somehow lost...
Executing 'updatemataveid' in the terminal gives an error:
Try to write path
in your Octave terminal, or MATLAB terminal. Does it looks like this?
>> path
Octave's search path contains the following directories:
.
/home/dell/program/matavecontrol
/home/dell/program/mataveid
.....
.....
more libs
No it does not!
I only have the directories in my search path that come with the downloaded folders.I think I did not follow the installation guidance properly...
Will check this and come back if there is still a problem.
That's the issue! :) Try to rename "sourcecode" to "mataveid". And remember! You need "matavecontrol" as well.
Hi Daniel,
just tried what you suggested.
matavecontrol and mataveid are now both in Octave's search path. I successfully updated both via the console using updatemataveid respectively udpatematavecontrol.
Now I get the following error for the OKID example code:
For the RLS example code I get the following error:
Any thoughts?
Hi Daniel,
just tried what you suggested.
matavecontrol and mataveid are now both in Octave's search path. I successfully updated both via the console using updatemataveid respectively udpatematavecontrol.
Now I get the following error for the OKID example code:
For the RLS example code I get the following error:
Any thoughts?
Please post the complete code.
OKID code example:
`% Load the data
X = csvread('.../libs/Mataveid-master/data/MultivariableCylinders.csv');
t = X(:, 1);
r0 = X(:, 2);
r1 = X(:, 3);
y0 = X(:, 4);
y1 = X(:, 5);
sampleTime = 0.1;
% Create the model
inputs = [r0';r1'];
states = [y0';y1'];
derivatives = (states(:, 2:end) - states(:, 1:end-1))/sampleTime;
states = states(:, 1:end-1);
inputs = inputs(:, 1:end-1);
t = t'(1, 1:end-1);
[sysd, K] = okid(inputs, states, derivatives', t, sampleTime);
% Do simulation
[outputs, T, x] = lsim(sysd ,inputs, t);
close
plot(T, outputs(1, :), t, states(1, :))
title('Cylinder 0');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);
figure
plot(T, outputs(2, :), t, states(2, :))
title('Cylinder 1');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);`
RSL code example:
`% Load data
X = csvread('.../libs/Mataveid-master/data/HangingLoad.csv');
t = X(:, 1); % Time
r = X(:, 2); % Reference
y = X(:, 3); % Output position
u = X(:, 4); % Input signal from P-controller with gain 3
sampleTime = 0.02;
% Do identification of the first data set
l = length(r) + 2000; % This is half data
% Do identification on up and down
sysd_up = rls(r(1:l/2), y(1:l/2), 1, 1, 1, sampleTime);
sysd_down = rls(r(l/2+1:end), y(l/2+1:end), 1, 1, 1, sampleTime);
% Simulate
[,,x] = lsim(sysd_up, r'(1:l/2), t'(1:l/2));
hold on
lsim(sysd_down, r'(l/2+1:end), t'(l/2+1:end), x(:, end));
hold on
plot(t, y);
legend('Up model', 'Down model', 'Measured');
title('Hanging load - Hydraulic system')
xlabel('Time [s]')
ylabel('Position');`
OKID code example:
`% Load the data
X = csvread('.../libs/Mataveid-master/data/MultivariableCylinders.csv');
t = X(:, 1);
r0 = X(:, 2);
r1 = X(:, 3);
y0 = X(:, 4);
y1 = X(:, 5);
sampleTime = 0.1;% Create the model
inputs = [r0';r1'];
states = [y0';y1'];
derivatives = (states(:, 2:end) - states(:, 1:end-1))/sampleTime;
states = states(:, 1:end-1);
inputs = inputs(:, 1:end-1);
t = t'(1, 1:end-1);
[sysd, K] = okid(inputs, states, derivatives', t, sampleTime);% Do simulation
[outputs, T, x] = lsim(sysd ,inputs, t);
close
plot(T, outputs(1, :), t, states(1, :))
title('Cylinder 0');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);
figure
plot(T, outputs(2, :), t, states(2, :))
title('Cylinder 1');
xlabel('Time');
ylabel('Position');
grid on
legend('Identified', 'Measured');
ylim([0 12]);`RSL code example:
`% Load data
X = csvread('.../libs/Mataveid-master/data/HangingLoad.csv');
t = X(:, 1); % Time
r = X(:, 2); % Reference
y = X(:, 3); % Output position
u = X(:, 4); % Input signal from P-controller with gain 3
sampleTime = 0.02;% Do identification of the first data set
l = length(r) + 2000; % This is half data% Do identification on up and down
sysd_up = rls(r(1:l/2), y(1:l/2), 1, 1, 1, sampleTime);
sysd_down = rls(r(l/2+1:end), y(l/2+1:end), 1, 1, 1, sampleTime);% Simulate
[,,x] = lsim(sysd_up, r'(1:l/2), t'(1:l/2));
hold on
lsim(sysd_down, r'(l/2+1:end), t'(l/2+1:end), x(:, end));
hold on
plot(t, y);
legend('Up model', 'Down model', 'Measured');
title('Hanging load - Hydraulic system')
xlabel('Time [s]')
ylabel('Position');`
Hmm...I don't get any errors.
Can you do this:
G = tf(1, [2 4 5]); % Random TF
u = gensig('square', 10, 50, 500); % Square wave, Amplitude = 10, 50 Hz, 500 sample time
t = linspace(0, 500, length(u)); % Time
y = lsim(G, u, t); % Linear simulation
sysd = rls(u, y, 2, 2, 2, t(2)-t(1)); % 2 poles, 2 zeros, 2 zeros for the noise polynomial
lsim(sysd, u, t); % Simulate the estimated model
hold on
lsim(G, u, t); % Simulate the real model and plot it directly on the estimated model
Yes I am using the control toolbox as I use some of the included functions.
Does your code matavecontrol provide all the functions that are included in control toolbox?
I can reinstall Octave and try to figure out if the problems are related to the use of the Octave control toolbox and or remove the control toolbox from the search path first.
Nevertheless I suggest to add the info to the Readme that you need to have matavecontrol to use mataveid and that one should not use the Octave control toolbox at the same time? Or does this work in general and it is only a problem of my installation?
Yes I am using the control toolbox as I use some of the included functions.
Does your code matavecontrol provide all the functions that are included in control toolbox?
I can reinstall Octave and try to figure out if the problems are related to the use of the Octave control toolbox and or remove the control toolbox from the search path first.
Nevertheless I suggest to add the info to the Readme that you need to have matavecontrol to use mataveid and that one should not use the Octave control toolbox at the same time? Or does this work in general and it is only a problem of my installation?
What you could to is to have the previous release of GNU Octave and install that with MataveID och MataveControl. Control-toolbox WILL cause problem for MataveID and MataveControl because they have the same function names.
The difference between MataveID/MataveControl and Control-Toolbox is that mine is 100% Opensource and have no external libraries. It's made for the user to read how the theory goes and be applied in practice :)
I can add that!
When you say previous release - which do you mean? I have the latest release 5.2.0.
So I should install 5.1.0 or an older release?
Has your code been tested/compared/verified against the Octave control toolbox?
When you say previous release - which do you mean? I have the latest release 5.2.0.
So I should install 5.1.0 or an older release?
Has your code been tested/compared/verified against the Octave control toolbox?
Try 5.1.0.
My code has been tested with MATLAB's Control-Toolbox.
For the SystemID functions, I have read a lot of books!
Ok this may take some days. I will let you know when tested. Thanks a lot for your support.
I have just tested removing the Octave control toolbox from Octave's search path. Afterwards it was possible to run the OKID as well as the RLS example.
I could also run the following code that you asked me to test.
G = tf(1, [2 4 5]); % Random TF
u = gensig('square', 10, 50, 500); % Square wave, Amplitude = 10, 50 Hz, 500 sample time
t = linspace(0, 500, length(u)); % Time
y = lsim(G, u, t); % Linear simulation
sysd = rls(u, y, 2, 2, 2, t(2)-t(1)); % 2 poles, 2 zeros, 2 zeros for the noise polynomial
lsim(sysd, u, t); % Simulate the estimated model
hold on
lsim(G, u, t); % Simulate the real model and plot it directly on the estimated model
So issue can be closed from my point of view.
If needed I will load the Octave control toolbox directly in my .m files instead of having it in the search path.