how to use a excel colum as an input to a function

3 Ansichten (letzte 30 Tage)
Giovanna Fiocco
Giovanna Fiocco am 10 Jul. 2020
Beantwortet: Mohit Kumar am 10 Jul. 2020
Hi everyone!
I'm doing a DoE for my laboratory experiment and I need to calculate my variables considering multiple input. I have 5 factors and 3 levels which will generate 3^5 = 729 variables which I need to insert in my function.
So my function worked in matlab, but I don't know how to use a colum from excel with multiple factors into my function. When I inputed the data from excel and associated to the variables, the function didn't returned the result because I didn't perfomed a point to point multiplication, but I don't know hot to change my function to do it.
Here's my function:
function [d50, rg, Jg, rm, A1, Jm, nm, vm, sigm, a, b, c, d]=diameter(hm, Pg, Pf, dtip, Ts)
%calculate d50
%Jg: gas flow, rg = gas density Pg: gas pressure
rg = ((4.5)*((1.6317*10^-6*(Pg))+1.0585));
Jg = ((2.704*10^-6)*(((rg)*(Pg))^0.5))
%Jm: metal flow, rm = metal density
%A1: tranversal area of the tip
%Ts: temperature
rm = (8346.309 -(0.86*(Ts)));
A1 = (pi*(((dtip)/2)^2));
a = (2*(Pf))+((19.6*(rm))*((hm)+0.08912))
b = (rm)*((1-3.11909e-5)/((A1)^2))
Jm = ((a)/(b))^0.5
%vm: kinematic viscosity, nm: dinamic viscosity
%sigm: surface tension
nm = (exp(-2.396+(7950/(Ts)))/1000);
vm = ((nm)/(rm));
sigm = ((2569.2-(0.4*(Ts)))*10^-3);
c =((vm)*(dtip)*(sigm))/((1.34e-5)*(530^2)*(rm))
d =(1+((Jm)/(Jg)))
d50 = (100e+6)*(((c)*(d))^0.5)
end
Thanks a lot for any help!
Giovanna

Antworten (1)

Mohit Kumar
Mohit Kumar am 10 Jul. 2020
Hi Giovanna,
To change your function so that it works with matrices, all you have to do is replace your multiplication and division operators into dot multiplication and dot division so that point to point multiplication and division is performed instead of matrix multiplication and equation solving. (Using the division operator between matrices (eg. A/B) causes MATLAB to look for a solution x of the equation xB=A)
That is change * into .*
and
Change / into ./

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by