How do I use the Arrhenis Equation in Matlab? - matlab

I need to use the equation k=k0*e^(-Q/RT) where T is 10 variables between 90 and 500, to generate the 10 variables I used T = linspace(90,500,10), but when I try to generate the equation it wont let me, k0=1200,Q=8000,R=2 so when I type in k=k0*exp(-Q./(R.*T) the numbers are kind of funky with some 0.0000, am I doing something wrong? Thanks

T = linspace(90,500,10);
k0=1200;
Q=8000;
R=2;
k=k0*exp(-Q./(R.*T));
format longG
k =
Columns 1 through 3
5.98693127135402e-17 1.83626027549851e-10 3.07185900119097e-07
Columns 4 through 6
2.60112352637493e-05 0.000498552970093129 0.00409767412987074
Columns 7 through 9
0.0198590098887835 0.067709291730596 0.180526236997812
Column 10
0.402555153483014
results = [T';k'];
Nothing wrong there, just the format that went wrong I reckon. For formatting options, see either the documentation on format, or this question.

Related

Tableau : Calculed field to transform series of odd numbers to a sequence of numbers

I need your help with the formulation for a calculed a field in Tableau (Tableau Prep to be accurate).
I have a field called [Code Order] which contains only a series of Odd numbers (1,3,5,7,9,..) multiple times, which means it can be (1,3,1,3,5,7,1,1,1,3,5,7,9,11).
What I need is to transform these in a normal sequence of numbers so for my example above I need as a result: (1,2,1,2,3,4,1,1,1,2,3,4,5,6)
In other words when in [Code Order] I have :
1 = 1
3 = 2
5 = 3
7 = 4
9 = 5
11 = 6
13 = 7
15 = 8
...
365 = 183
For the moment my maximum is 365, which is position 183, I would like to avoid to type 182 IF formulas if possible. ;)
Thanks in advance for your help.
CYA
Plt.K
This might turn out to be more accurate in case your Code Order series is missing any values along the way.
Example series:
Alternate Field:
Tableau Setup:
You want to use the index() calculated field. Create a new field called index. The calculation is just index().
Add [Code Order] to your row shelf and index to your label. You should see something like this.
The following calculation should do the trick
CEILING([Code Order] / 2)

How to read .csv file from a different location in MATLAB?

I'm new to MATLAB, I've been fiddling around to import a .csv file which is on my desktop to MATLAB. I've already tried csvread() function as shown,
M = csvread(C:/Users/XYZ/Desktop/train.csv)
Please help. Thanks in advance.
EDIT:
My data is in the following format:
Id DV T1 T2
1 1 15 3
2 4 16 14
3 1 10 10
4 1 18 18
The csvread method takes a string (i.e. a char type) for the filename. In matlab a char must be expressed inside quotation marks, so this should work:
M = csvread('C:/Users/XYZ/Desktop/train.csv')

Function equivalent to SUM() for multiplication in SQL Reporting

I'm looking for a function or solution to the following:
For the chart in SQL Reporting i need to multiply values from a Column A. For summation i would use =SUM(COLUMN_A) for the chart. But what can i use for multiplication - i was not able to find a solution so far?
Currently i am calculating the value of the stacked column as following:
=ROUND(SUM(Fields!Value_Is.Value)/SUM(Fields!StartValue.Value),3)
Instead of SUM i need something to multiply the values.
Something like that:
=ROUND(MULTIPLY(Fields!Value_Is.Value)/MULTIPLY(Fields!StartValue.Value),3)
EDIT #1
Okay tried to get this thing running.
The expression for the chart looks like this:
=Exp(Sum(Log(IIf(Fields!Menge_Ist.Value = 0, 10^-306, Fields!Menge_Ist.Value)))) / Exp(Sum(Log(IIf(Fields!Startmenge.Value = 0, 10^-306, Fields!Startmenge.Value))))
If i calculate my 'needs' manually i have to get the following result:
In my SQL Report i get the following result:
To make it easier, these are the raw values:
and you have the possibility to group the chart by CW, CQ or CY
(The values from the first pictures are aggregated Sum values from the raw values by FertStufe)
EDIT #2
Tried your expression, which results in this:
Just to make it clear:
The values in the column
=Value_IS / Start_Value
in the first picture are multiplied against each other
0,9947 x 1,0000 x 0,59401 = 0,58573
Diffusion Calenderweek 44 Sums
Startvalue: 1900,00 Value Is: 1890,00 == yield:0,99474
Waffer unbestrahlt Calenderweek 44 Sums
Startvalue: 620,00 Value Is: 620,00 == yield 1,0000
Pellet Calenderweek 44 Sums
Startvalue: 271,00 Value Is: 160,00 == yield 0,59041
yield Diffusion x yield Wafer x yield Pellet = needed Value in chart = 0,58730
EDIT #3
The raw values look like this:
The chart ist grouped - like in the image - on these fields
CY (Calendar year), CM (Calendar month), CW (Calendar week)
You can download the data as xls here:
https://www.dropbox.com/s/g0yrzo3330adgem/2013-01-17_data.xls
The expression i use (copy / past from the edit window)
=Exp(Sum(Log(Fields!Menge_Ist.Value / Fields!Startmenge.Value)))
I've exported the whole report result to excel, you can get it here:
https://www.dropbox.com/s/uogdh9ac2onuqh6/2013-01-17_report.xls
it's actually a workaround. But I am pretty sure is the only solution for this infamous problem :D
This is how I did:
Exp(∑(Log(X))), so what you should do is:
Exp(Sum(Log(Fields!YourField.Value)))
Who said math was worth nothing? =D
EDIT:
Corrected the formula.
By the way, it's tested.
Addressing Ian's concern:
Exp(Sum(Log(IIf(Fields!YourField.Value = 0, 10^-306, Fields!YourField.Value))))
The idea is change 0 with a very small number. Just an idea.
EDIT:
Based on your updated question this is what you should do:
Exp(Sum(Log(Fields!Value_IS.Value / Fields!Start_Value.Value)))
I just tested the above code and got the result you hoped for.

Arrange data using loop in MATLAB

If I have:
t=(1:1:5)'
time=1:3:100
How do I arrange data t in each column starting from 1 until the end, with an interval of 3. Which means that the data t (1 to 5) at column 1,4,7 and so on.
I've tried:
t=[1:1:5];
nt=length(temp);
time=[1:1:100];
nti=length(time);
x=zeros(nt,nti);
temp=temp';
initiator=2;
monomer=3;
post=1:3:100;
for l=1:post
step=1;
maxstep=100;
while (step<maxstep)
step=step+3;
temp=(1:1:5)';
end
t(:,l)=t;
x=[t];
end
This only shows result X with temp at column 1. I do not know how to to arrange this data at columns that I want.
Hope someone will help me. Thank you in advance.
How many dimensions does your data have? If you already have "temp" (temperature?) and "time" as your first two dimensions and you want "t" to be the third dimension, then create a three-dimension matrix.
To extract from indexes [1 4 7 10 13 16 ... ], use (1:3:end)
To extract from indexed [2 5 8 11 14 17 ... ], use (2:3:end)
In MATLAB's colon notation, the first value is the start. Second value is increment. Third value is the end value and is inclusive.

MATLAB result is inappropriate

I'm new in MATLAB, i cannot get the answer in the format that i want.
I have a basic function call, but every execution of the program gives the result in the following format :
357341279027200000/23794118819840001
It's supposed to be in decimal, for example for same execution : 15.0181.
I could not figure out why this is happening ? Can you help me, thank you !!
Type format long on the command prompt or in your script.
If that doesnt work because the value is too large, try using vpa
Note that it's just visual, internally the value computed is precise.
>d = 357341279027200000/23794118819840001
d =
15.0181
>> d * 23794118819840001 == 357341279027200000
ans =
1
>> 15.0181 * 23794118819840001 == 357341279027200000
ans =
0
Are you sure that you are not using format rat (rational). This is the reason why you may be having fractional values. If you want decimals, try format long or format long g (Long g provides the optimal length and accuracy as a decimal, up to 10 places.)