I want to set the coefficient of my PID controller (P, I and D) as variables.
I want P, I and D coming from the 3 inports 2, 3 and 4 as represented in the picture
enter image description here
I tried to create P, I and D variables in the workspace. The PID block can read it (the error in the picture is due to I removed them from the workspace later).
However, how can I link the inports to the P, I and D variables and to update continuously the coefficients of the PID ? What block should I used ?
I would prefer not using a matlab script.
Thank you for your help.
Best regards.
RĂ©mi.
Change the PID block from "internal" to "external" - you can see this in your screenshot under the "source" menu - this will turn the P,I and D terms into inputs to your PID block, that you can then wire to the submodule inputs
Related
I run a command in the terminal that outputs the below..
abc -> 1
bcd -> g
cde -> 2
def -> 3
efg -> 4
That you see on the left of -> represents first parameter of another function and that you see on the right of -> represents the second parameter of the same function.
What you see on the left is essentially paired with what is on the right, and I want to utilise this information in the other function.
I had the idea of outputting what's on the left into one file and
outputting what's on the right into another file
Then creating a function that reads both files and pulls out the
information one by one and uses it in the other function until all
information has been used i.e. after efg -> 4 has been
used in the other function then it would stop.
My questions are:
How can different values be used as the same parameter one after another?
How can you pair two pieces of information from two separate files? So that the first of the pair is run as one parameter and the second of the pair is run as the other parameter.
Is there a better approach to this?
Shell scripts are great for processing text and running commands. There's no need for temporary files. A simple loop can do it:
some_command | while read -r param1 _ param2; do
use_values "$param1" "$param2"
done
Here some_command is a placeholder for the command that prints the output above and use_values is a placeholder for the "other function" that uses the two values.
I used _ as a variable name for the -> bit, which is ignored. _ is a common idiom to indicate a variable that isn't used.
The 1..T function is not working for me, and I don't know why. My code looks like this:
set TIME;
data;
set TIME = 1..8760 by 3;
display TIME;
Here I want it to display 1, 4, 7, 10, and so on, but it just goes 1..8760 by 3. How can I fix this so that I don't have to write 8,760 different numbers?
Thankful for answers!
I don't find any error in your code. I tried in my AMPL IDE:
AMPL IDE
I suppose that when you write "data" is that your code is in the .dat file and when you write "display" is your .run file
What are you using to write your model?? NEOS SERVER or the IDE??
Regards!
Try deleting the first two lines of your code.
It looks as if the format you're using to specify TIME only works in "model" mode; in "data" mode, the same text is interpreted as declaring a set of literals "3", "by", and "1..8760". (Quick test: if you type display card(TIME); you get a value of 3, telling you that there are exactly 3 members in this set.)
Section 5.2 of the AMPL Book recommends using a "x..y by z" type declaration in the model (with x, y, z as declared params) and then specifying values for x, y, z in the data.
Note that starting at 1 and increasing in steps of 3 won't actually get to 8760 exactly, so you might want to change your start to 0 or 3, or your end to 8761, if you want equal gaps between the numbers.
I have created syntax in SPSS that gives me 90 separate iterations of general linear model, each with slightly different variations fixed factors and covariates. In the output file, they are all just named as "General Linear Model." I have to then manually rename each analysis in the output, and I want to find syntax that will add a more specific name to each result that will help me identify it out of the other 89 results (e.g. "General Linear Model - Males Only: Mean by Gender w/ Weight covariate").
This is an example of one analysis from the syntax:
USE ALL.
COMPUTE filter_$=(Muscle = "BICEPS" & Subj = "S1" & SMU = 1 ).
VARIABLE LABELS filter_$ 'Muscle = "BICEPS" & Subj = "S1" & SMU = 1 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMATS filter_$ (f1.0). FILTER BY filter_$.
EXECUTE.
GLM Frequency_Wk6 Frequency_Wk9
Frequency_Wk12 Frequency_Wk16
Frequency_Wk20
/WSFACTOR=Time 5 Polynomial
/METHOD=SSTYPE(3)
/PLOT=PROFILE(Time)
/EMMEANS=TABLES(Time)
/CRITERIA=ALPHA(.05)
/WSDESIGN=Time.
I am looking for syntax to add to this that will name this analysis as: "S1, SMU1 BICEPS, GLM" Not to name the whole output file, but each analysis within the output so I don't have to do it one-by-one. I have over 200 iterations at times that come out in a single output file, and renaming them individually within the output file is taking too much time.
Making an assumption that you are exporting the models to Excel (please clarify otherwise).
There is an undocumented command (OUTPUT COMMENT TEXT) that you can utilize here, though there is also a custom extension TEXT also designed to achieve the same but that would need to be explicitly downloaded via:
Utilities-->Extension Bundles-->Download And Install Extension Bundles--->TEXT
You can use OUTPUT COMMENT TEXT to assign a title/descriptive text just before the output of the GLM model (in the example below I have used FREQUENCIES as an example).
get file="C:\Program Files\IBM\SPSS\Statistics\23\Samples\English\Employee data.sav".
oms /select all /if commands=['output comment' 'frequencies'] subtypes=['comment' 'frequencies']
/destination format=xlsx outfile='C:\Temp\ExportOutput.xlsx' /tag='ExportOutput'.
output comment text="##Model##: This is a long/descriptive title to help me identify the next model that is to be run - jobcat".
freq jobcat.
output comment text="##Model##: This is a long/descriptive title to help me identify the next model that is to be run - gender".
freq gender.
output comment text="##Model##: This is a long/descriptive title to help me identify the next model that is to be run - minority".
freq minority.
omsend tag=['ExportOutput'].
You could use TITLE command here also but it is limited to only 60 characters.
You would have to change the OMS tags appropriately if using TITLE or TEXT.
Edit:
Given the OP wants to actually add a title to the left hand pane in the output viewer, a solution for this is as follows (credit to Albert-Jan Roskam for the Python code):
First save the python file "editTitles.py" to a valid Python search path (for example (for me anyway): "C:\ProgramData\IBM\SPSS\Statistics\23\extensions")
#editTitles.py
import tempfile, os, sys
import SpssClient
def _titleToPane():
"""See titleToPane(). This function does the actual job"""
outputDoc = SpssClient.GetDesignatedOutputDoc()
outputItemList = outputDoc.GetOutputItems()
textFormat = SpssClient.DocExportFormat.SpssFormatText
filename = tempfile.mktemp() + ".txt"
for index in range(outputItemList.Size()):
outputItem = outputItemList.GetItemAt(index)
if outputItem.GetDescription() == u"Page Title":
outputItem.ExportToDocument(filename, textFormat)
with open(filename) as f:
outputItem.SetDescription(f.read().rstrip())
os.remove(filename)
return outputDoc
def titleToPane(spv=None):
"""Copy the contents of the TITLE command of the designated output document
to the left output viewer pane"""
try:
outputDoc = None
SpssClient.StartClient()
if spv:
SpssClient.OpenOutputDoc(spv)
outputDoc = _titleToPane()
if spv and outputDoc:
outputDoc.SaveAs(spv)
except:
print "Error filling TITLE in Output Viewer [%s]" % sys.exc_info()[1]
finally:
SpssClient.StopClient()
Re-start SPSS Statistics and run below as a test:
get file="C:\Program Files\IBM\SPSS\Statistics\23\Samples\English\Employee data.sav".
title="##Model##: jobcat".
freq jobcat.
title="##Model##: gender".
freq gender.
title="##Model##: minority".
freq minority.
begin program.
import editTitles
editTitles.titleToPane()
end program.
The TITLE command will initially add a title to main output viewer (right hand side) but then the python code will transfer that text to the left hand pane output tree structure. As mentioned already, note TITLE is capped to 60 characters only, a warning will be triggered to highlight this also.
This editTitles.py approach is the closest you are going to get to include a descriptive title to identify each model. To replace the actual title "General Linear Model." with a custom title would require scripting knowledge and would involve a lot more code. This is a simpler alternative approach. Python integration required for this to work.
Also consider using:
SPLIT FILE SEPARATE BY <list of filter variables>.
This will automatically produce filter labels in the left hand pane.
This is easy to use for mutually exclusive filters but even if you have overlapping filters you can re-run multiple times (and have filters applied to get as close to your desired set of results).
For example:
get file="C:\Program Files\IBM\SPSS\Statistics\23\Samples\English\Employee data.sav".
sort cases by jobcat minority.
split file separate by jobcat minority.
freq educ.
split file off.
I want to generate a fixed random variable ~N(0,10) for every observation for future computation.
gen X=rnormal (0,10)
list X
Blank
How can I see what value of X is being generated?
You were probably using an empty dataset when you issued these commands. In that case you would first need to tell Stata how many observations your dataset contains. For that you need to use the set obs command, so something like:
. set seed 12345
. set obs 10
obs was 0, now 10
. gen x = rnormal(0,10)
. list, clean
x
1. -9.580833
2. -2.907274
3. 8.45202
4. 8.617108
5. -12.19151
6. 9.457337
7. 1.722469
8. -13.29949
9. -11.5291
10. 25.1646
Think of what would happen when you did not use set obs. In that case Stata would see gen x = rnormal(0,10) and think "ok, I need to create random draws from a normal distribution, but how many?". If you had a dataset open, then it would answer "as many as there are observations in the dataset". If you had no dataset open, then the answer would still be "as many as there are observations in the dataset", but that happens to be 0.
Edit:
If you just want one number you are best of using scalars and not variables. In Stata a scalar refers to a single number and a variable refers to a single column in your dataset. For scalars it is best to use temporary names, as they share the same namespace as variables but variables take precedence when it comes to abreviations, which can lead to unexpected behaviour. So you could do something like:
. tempname a
. scalar `a' = rnormal(0,10)
. di `a'
10.737423
I'm trying to integrate a Web scheduling appliance with my organization's calendar system, Oracle Calendar 10. Getting meetings out is just a matter of parsing the UNICPOUTR output, and I thought I had a handle on getting meetings in with UNICPINR, but I'm getting a couple of odd errors.
Basically I grab the room description from UNICPOUTR, append the data for the new meeting, write out to /usr/tmp, and try to import the resulting file. I created a test resource to try things out, but something's gone odd. Here's the resource description from UNICPOUTR:
{
F Unison Export File
V A.02.53
E FALSE
X
R a Test Resource
R b
R c 10
R d
R e
R f
R g
I
P 4 480 1080 1 30 190 2 1 60 0 0 10
N 0
}
But trying to use this as a basis for an import file results in the rather odd error:
"R=Test Resource/N=Test Resou/CA=10/LOC=10/PHONE=10/EXT=10/FAX=10/PSW=g"
does not exist
Trying to get a handle on the resource with the -ls flag on UNICPINR, as
unicpinr -ls /usr/tmp/meeting.test
just spits out
unicpinr: file pattern not found - First
after a message on how to use the utility.
Is anybody out there familiar enough with the system that they can tell me what's going wrong here, or better yet suggest an alternate way to get new meetings in?
Okay, so after spending a day chewing on it, I've come up with this solution. There were a couple problems at work here (notwithstanding the -ls which I haven't investigated).
First: while UNICPOUTR will produce blank lines for acceptable nulls in the resource description, UNICPINR will for some reason assume that a blank line means to use the value from the previous line of input.
Second: UNICPINR doesn't seem to be able to search on anything other than the resource name.
Solution: take the resource description block and filter out the lines that start with X (room administrator), I (room password), and "R b" through "R g" (various resource identifiers). UNICPINR can run a search with "R a" just fine.
The resulting import, however, leaves all the meetings thinking they were created (M) and owned (W) by the room itself, but the original creator/owner are in the comments section prefaced by "Event creator: " and "Event owner: ", so I can work with that.
This may be a problem that only I will ever face, but it's responsible to leave the solution, however kludgy, in case someone else is out there groping about blindly. So here it is.