Function for the equation

์กฐํšŒ ์ˆ˜: 5 (์ตœ๊ทผ 30์ผ)
Betty Johnson
Betty Johnson 2021๋…„ 3์›” 10์ผ
๋Œ“๊ธ€: Walter Roberson 2021๋…„ 3์›” 12์ผ
Is there any way to define a function for this equation? ln(๐›ฝ/(T^2))=โˆ’๐ธ/๐‘…*1/๐‘‡+ ln(๐‘…/๐ธ * ๐ด)
I am tryting to use different spreadsheets of an excel to calculate this function.So i would like to know how to write code as a function to apply it to all different spreadsheets
  ๋Œ“๊ธ€ ์ˆ˜: 4
Walter Roberson
Walter Roberson 2021๋…„ 3์›” 10์ผ
Is this a curve fitting question then? You have a spreadsheet with multiple sheets, one holds beta, one holds T, one holds R, and you would like to find the best single E and A values that model the system?
Betty Johnson
Betty Johnson 2021๋…„ 3์›” 10์ผ
No all the speadsheets have the list of values for all parameters except fot E and A and I need to find E and A for all those sheets.So I am trying to define a function which would make the task easier

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

๋‹ต๋ณ€ (1๊ฐœ)

Walter Roberson
Walter Roberson 2021๋…„ 3์›” 10์ผ
If you have
log(beta/T^2) = -E/(R*T) + log(R*A/E)
and you need to solve for R, then
R = E ./ (T .* lambertw(T .* A ./ beta))
If instead you need to solve for T then
%under the assumption that A, beta, E, R are all non-negative !!
inner = sqrt(E*A/(R*beta))/2
outer = E/(2*R);
T = [outer/lambertw(inner), outer/lambertw(-inner)]
Depending on the exact values involved, the first of the two T entries might be complex
If any of A, beta, E, R, might be negative, then the inner becomes more complicated,
inner = sqrt(E.^2./(R.^2.*beta)).*sqrt(R.*A./E)/2
  ๋Œ“๊ธ€ ์ˆ˜: 2
Betty Johnson
Betty Johnson 2021๋…„ 3์›” 10์ผ
The unknowns are E and A
Walter Roberson
Walter Roberson 2021๋…„ 3์›” 12์ผ
xlsfile = 'YourFileName.xlsx';
[status, sheetnames] = xlsxinfo(xlsfile);
if isempty(status)
error('cannot read file "%s" as an excel file', xlsfile);
end
numsheets = length(sheetnames);
EA = zeros(numsheets,2);
for K = 1 : length(sheetnames)
thissheet = sheetnames{K};
Tab = readtable(xlsfile, thissheet);
beta = Tab{:,1}; %adjust column numbers as appropriate
T = Tab{:,2};
R = Tab{:,3};
guess = [1,3/4];
residue = @(E,A) sum((-E./(R.*T) + log(R.*(A./E)) - log(beta./T.^2)).^2,1);
EA(K,:) = fminsearch(residue, guess);
end
I do not have your file to test with so I have no idea how close to the global minima the above will get.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Spreadsheets์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

Community Treasure Hunt

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

Start Hunting!

Translated by