Edit data in tecplot - paraview

The results I get in tecplot through the generated .vtk files are too small (eg magnitude of ^-18) this is because I run an analysis through a scaled down model.
I would like to give the results in a exagerated form so that deflection and stresses are very visible. So I need to multiply my results with a factor.
Can I do this in the tecplot interface or should I find a way to write the .vtk files with a magnification factor.
A method to do either would be much appreciated.
PS - I have used the calculator in paraview so is there something similar in tecplot ?
Thanks

You can create a new variable using the tecplot calculator. It is in :
Data > Alter > Specify Equations
In this menu :
select the zone you want to alter (in case of doubt, select all the zones)
create a new variable NEW_VAR that will be the original variable VAR multiplied by a factor (eg. 100) :
{NEW_VAR} = {VAR}*100
use the "Compute" button
NB :
Variables names must be put between braces
You can find the names of the variables with the "Data Set Info..." button, in the top right corner of the "Specify Equations" menu.

Related

How to copy data from a 1 x 1 double timeseries to a 1 D Lookup Table in Matlab

I have been asked to look at a Matlab project. I'll link sceenshots to clarify the problem. I need to create a 1 D Lookup table with the data from a 1 x 1 double timeseries from another model that has been supplied. One problem is that there are a lot of data points (12500). Is it possible to copy these points across without having to drag the mouse down over the whole 12500 points? Someone has actually tried this dragging the mouse over all the points method and said it didn't work anyway, but I don't really want to try it myself, as it would be way to cumbersome for my liking, even if it did work.
Here is an example of what the 1 x 1 double timeseries looks like (just using 5 points instead of 12500 for simplicity's sake):
Here is the model with the 1D look up table highlighted in blue at the left:
Here is what the 1-D lookup table looks like when opened:
Any insight appreciated.
I've worked out how to copy the data from the timeseries table (actually from the input to this, which is a 1 x 1 struct), but he problem is that the values have no commas between them and the 1-D lookup table requires commas.
Note that the problem has now been solved using Excel, although not by the method I was trying to make work in the question. An answer has been posted which may work, but I'm not sure if i will go to the trouble of attempting to implement it or not at this stage. However, if need be and all being well, I will either do that or delete the question.
You can import a look-up table object (Simulink.LookupTable-object) from both, the MATLAB workspace or directly from Excel.
If you want to automate it, it basically comes down to these two points:
"
Open the model containing the lookup table block and in the Modeling tab, select Model Settings.
In the Model Properties dialog box, in the Callbacks tab, click PostLoadFcn callback in the model callbacks list.
... the next time you open the model, Simulink® invokes the callback and imports the data.
"
After a little thought I feel like the answer is actually fairly trivial: it just can't be done. The input field of the look up table just can't hold 12500 points, most of which have 9 or so decimal places, so there's no way to do this.
This isn't to say there's no way to put the data into the model: this can be done using Excel.

Tableau percentage change of same measure

I have added a very simple example Tableau here: https://drive.google.com/file/d/1yG7EdIrKrTklhWOEoAmM4xwSbFZpOTvf/view?usp=sharing
In this example what I would like to achieve is to have a % change column which shows the % change.
I've tried using Quick table calculations but I cannot find any calculation that allows me to get the % change. I've also tried to use a calculated field with IF statements, but the calculation was returning blank cell.
P.S.
This is part of a more complex example in this thread: https://community.tableau.com/message/753038#753038
I have followed the answer in the link above and I was able to get to the point where I have the data showing up in two separate columns "Current Year" and "Prior Year".
But then I'm stuck on the supposedly easy step of simply calculating the % change between those two columns.
I was able to solve this issue by right clicking on the measure and selecting "Add Table Calculation".
Then I choose Calculation Type = "Percent Difference From", computing using = "Table (across)" and finally relative to = "Previous"

How to call simulink model(.slx) from script

I'm a super beginner in Simulink models and control systems.
I have .slx Simulink model for drone dynamics system.
It takes in two inputs (roll cmd, pitch cmd) and outputs velocity x, velocity y, position x, and position y.
From here, it seems like I can open the system by calling
open_system('myModel.slx', 'loadable');
But how do I put inputs and get output values?
Is there a way I can do this in a gui?
EDIT:
Here is the full layout of my model:
When I did
roll_CMD=10;
pitch_CMD=20;
I got a warning saying:
Input port 1 of 'SimpleDroneDynamics/...' is not connected.
How do I feed inputs using port numbers?
How do I get outputs with port numbers? I tried
[vx, vy, px, py] = sim('SimpleDroneDynamics.slx');
and got an error saying
Number of left-hand side argument doesn't match block diagram...
Is there a way to continuously feed inputs at every time step? This being controller module, I think I'm supposed to feed in different values based on output position and velocity.
EDIT2:
I'm using Matlab2017a
About the first two points of your question:
In simulink:
For the inputs you can use a constant block and when you double click the input block you can assign a value, which can be a workspace variable.
To get the outputs to your workspace you can use the simout block (make sure to put Save format to array).
Connect inputs to your simulink model
Connect outputs of your simulink model to the simout blocks.
MATLAB script
clc;
clear all;
roll = 10;
pitch = 20;
sim('/path_to_simulinkmodel.slx')
time = simout(:,1);
velocity_X = simout(:,2);
velocity_Y = simout(:,3);
position_X = simout(:,4);
position_Y = simout(:,5);
About the third point of your question
You can define the duration of your simulation in the block diagram editor. You can put a variable which is defined in the calling script. There are multiple ways of achieving time dependent input variables:
One option I personally don't recommend is using a for-loop and calling the simulink model with a different value of roll and pitch
for i = 1:numberOfTimesteps
roll = ...
...
sim('simulinkModel.slx')
end
A second and more efficient approach is changing the constant blocks to other source blocks like ramp signals or sinusoid signals
First of all Simulink model use main Matlab workspace. So you can change your variables values at command window (or just at your script) and run Simulink model.
There are several ways to initialize this constants for Simulink. One more useful way is to create script containing all your variables and load it at Simulink model starts. You can do it by adding script name in Simulink/Model Explorer/Callbacks. (There are different callbacks - on Loading, on Starting and etc.). Read more about this: here.
Now you can run your simulation using sim function:
sim('name_of_model')
name_of_model must contain path if model is not in the active MATLAB folder (active folder you can see in your matlab window just under the main menu).
There are different properties of sim function, read about them in help this can be useful for you. By the way: you can change some parameters of your model using sim. You even can find any block in your model and change it's properties. Read more about sim and about finding current blocks. Interesting that the last solution give you ability to change parameters during the simulation!
About getting output. After you run simulation you get tout variable in main workspace. It is an array of timesteps. But if you add outport block (like at my image) you also get another variable in workspace yout. yout is an Datasets. It contain all your outports values. For 2 outports for example:
yout
yout =
Simulink.SimulationData.Dataset
Package: Simulink.SimulationData
Characteristics:
Name: 'yout'
Total Elements: 2
Elements:
1 : ''
2 : ''
Get the values of any of outports:
yout.get(1).Values
it is a timeseries data type, so:
yout.get(1).Values.Time - give you times
yout.get(2).Values.Data - give you values of this outport at each time
We have one more method to take output values:
[t,x,y] = sim('model_name')
it returns double arrays. t- time array, y - matrix of all outports values (it already double and contain only values without times, but for each simulation time!)
So now you can create common Matlab GUI and work at this variables! There is no any difficulties. You can read more about GUI for Simulink here.

Searching constant value through all Simulink blocks

I have a big Simulink model with a lot of User-Defined MATLAB functions. And I went wrong way - I used some local data in many blocks. For example - water density. I just used 1000 in formulas or some local variables like this: wat_den = 1000; in a lot of different functions (MATLAB function blocks).
And now I got the problem - I tried to simulate my model for another liquid (so, another density). Now I understand, that I have to use all this variables in another way - I create table of all constant and route them to functions directly.
And my question - is it possible to find variable or numeric value in all functions? because Ctrl+F can't finds inside of any user-defined functions (it can find only signal's names, port names, etc) and I forced to open every block and check it's content.
you can easily do this by doing CTRL + SHIFT + F
It will open up a gui and you can write in the field: *Find Files containing text: * the name of your variable.
This will search all the instances of that variable throughout your Current Folder (you can even change where to search).
Note: You can change the extension of the file you want to search.
I hope this helps. I am using Matlab r2015b

where do i put a formula in matlab

I have no matlab or mathematical experience but i would like to do the following :
convert an excel file to a tab delimited file and open this in matlab organized in the following way:
every row is a new subject
first colum is name of subject
other 8 columns are the parameters for each subject
I would like to run a growthfunction on each subject and obtain the following results
the maximum velocity and corresponding growth and time
the minimum velocity before the maximum velocity is reached and corresponding time and growth
the maximum growth (the function nears an asymptot)
-This is the code that I would use
tmin=0;
tmax=20;
dt=1
t=tmin:dt:tmax;
y = m1.*(1-1./(1+(m2.*(t+m8)).^m5+(m3.*(t+m8)).^m6+(m4.*(t+m8)).^m7));
dy=diff(y)./dt;
max(dy);
min(dy);
imax=find(dy==max(dy))+1;
imin=find(dy==min(dy))+1;
t(imax);
t(imin);
y(imax);
y(imin);
y(20);
Where do i put this code so that it knows that m1 to m8 are corresponding to the different columns in my file? how do i link these?
How can i make sure that the output of each subject appears in a column in my tab delimited file (like excel)
In brief what I would like to do:
have a file with on every row a new subject and column 2-9 are the values of the parameters m1 to m8. Run the formula so that in column 9 i will have the maximum velocity, in 10 the minimum velocity and so one...
Can anyone help me out
Thanks
[~,~,rawData]=xlsread('yourExcelSheet.xlsx')
SubjectNames=rawData(:,1) % I think () is better here than { }, may have to switch this up.
Data=cell2mat(rawData(:,2:9)) % convert the last 8 columns (2 to 9) to a matrix of type double
%This ^^ also assumes there are no headers in excel, if there are headers, it would be %rawData(2:end,2:9) instead of what I have above
m1=Data(:,2)
m2=Data(:,3)
% etc. etc.
m8=Data(:,9)
alternatively, if you can get over the messiness, substitute "Data(:,2)" in your equation instead of m1, it will give you a tiny speedup
Disclaimer: I just wrote all this off the top of my head, if it errors, hopefully its just something small, otherwise let me know.
you can just import the data by double clicking the xls file. A dialog should appear. Select the data range that you want to import.
you can then simply state untitled(:,1) = m1 etc.