# Read Excel and write the output in same sheet in three columns

2 vues (au cours des 30 derniers jours)
MINATI PATRA le 14 Jan 2024
Commenté : MINATI PATRA le 15 Jan 2024
status = mkdir('D:\PK90'); cd D:\PK90
filename = 'sample.xlsx'; % path to your file, e.g., 'D:\PK79\Book1.xlsx'
% read the file to a table:
Q = 1; Da = 0.5; K = 0.1; G = 0.1; bt = 2; Pr = 2; Nb = 0.1; Nt = 0.1;
Le = 1; K1 = 0.01; a1 = 0.1; a2 = 0.1; % Rd = 0.75; A = 0.15; B = 0.15;
BC = @(ya,yb)[ ya(1); ya(2)-1; ya(5) + a1*(1-ya(4)); ya(7) + a2*(1-ya(6)); yb([2,4,6]); ];
ODE = @(x,y) [ y(2); y(3); (-y(1)*y(3) + y(2)^2 - Q*exp(-bt*x) + Da*y(2))/(1+K-K*G*y(3)^2);
y(5); ((-Pr*(Nb*y(5)*y(7) + y(1)*y(5) + Nt*y(5)^2)) - A*y(2) - B*y(4))/(1+(4*Rd)/3);
y(7); -Le*Pr*(y(1)*y(7) - K1*y(6)) - (Nt/Nb)*((-Pr*(Nb*y(5)*y(7) + y(1)*y(5) + Nt*y(5)^2)) - A*y(2) - B*y(4))/(1+(4*Rd)/3);];
xa = 0;xb = 6; x = linspace(xa,xb,100); solinit = bvpinit(x,[0 1 0 1 0 1 0]); sol = bvp5c(ODE,BC,solinit); S = deval(sol,x);
Cf = ( (1+K)*S(3,1) - ((K*G*S(3,1)^3)/3)); Nu = -(1 + (4*Rd)/3)*S(5,1); Sh = -S(7,1);
disp ([Cf Nu Sh])
writetable(T,filename,'WriteMode','overwritesheet')
% check the result:
%% I need to write the calculations of Cf, Nu and Sh in the sheet
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Voss le 14 Jan 2024
@MINATI PATRA: Check and see if this seems right:
filename = 'sample.xlsx'; % path to your file, e.g., 'D:\PK79\Book1.xlsx'
% read the file to a table:
T = 20×7 table
Rd A B Var4 Var5 Var6 Nu ____ ____ ____ ____ ____ ____ ______ 0.5 0.1 0.1 NaN NaN NaN 0.1321 1 0.1 0.1 NaN NaN NaN 0.179 0.5 0.2 0.1 NaN NaN NaN 0.1213 1 0.2 0.1 NaN NaN NaN 0.1654 0.5 0.1 0.2 NaN NaN NaN 0.1285 1 0.1 0.2 NaN NaN NaN 0.1729 0.5 0.2 0.2 NaN NaN NaN 0.1162 1 0.2 0.2 NaN NaN NaN 0.1573 0.5 0.15 0.15 NaN NaN NaN 0.1247 1 0.15 0.15 NaN NaN NaN 0.169 0.75 0.1 0.15 NaN NaN NaN 0.1536 0.75 0.2 0.15 NaN NaN NaN 0.1406 0.75 0.15 0.1 NaN NaN NaN 0.1497 0.75 0.15 0.2 NaN NaN NaN 0.144 0.75 0.15 0.15 NaN NaN NaN 0.1471 0.75 0.15 0.15 NaN NaN NaN 0.1471
Q = 1; Da = 0.5; K = 0.1; G = 0.1; bt = 2; Pr = 2; Nb = 0.1; Nt = 0.1;
Le = 1; K1 = 0.01; a1 = 0.1; a2 = 0.1; %Rd = 0.75; A = 0.15; B = 0.15;
Rd = T.Rd;
A = T.A;
B = T.B;
xa = 0;
xb = 6;
x = linspace(xa,xb,100);
N = size(T,1);
Cf = zeros(N,1);
Nu = zeros(N,1);
Sh = zeros(N,1);
for k = 1:N
BC = @(ya,yb)[ ya(1); ya(2)-1; ya(5) + a1*(1-ya(4)); ya(7) + a2*(1-ya(6)); yb([2,4,6]); ];
ODE = @(x,y) [ y(2); y(3); (-y(1)*y(3) + y(2)^2 - Q*exp(-bt*x) + Da*y(2))./(1+K-K*G*y(3)^2);
y(5); ((-Pr*(Nb*y(5)*y(7) + y(1)*y(5) + Nt*y(5)^2)) - A(k)*y(2) - B(k)*y(4))./(1+(4*Rd(k))/3);
y(7); -Le*Pr*(y(1)*y(7) - K1*y(6)) - (Nt/Nb)*((-Pr*(Nb*y(5)*y(7) + y(1)*y(5) + Nt*y(5)^2)) - A(k)*y(2) - B(k)*y(4))./(1+(4*Rd(k))/3);];
solinit = bvpinit(x,[0 1 0 1 0 1 0]);
sol = bvp5c(ODE,BC,solinit);
S = deval(sol,x);
Cf(k) = ( (1+K)*S(3,1) - ((K*G*S(3,1)^3)/3));
Nu(k) = -(1 + (4*Rd(k))/3)*S(5,1);
Sh(k) = -S(7,1);
end
disp ([Cf Nu Sh])
-0.9792 0.1321 0.0870 -0.9792 0.1790 0.0872 -0.9792 0.1213 0.0884 -0.9792 0.1654 0.0884 -0.9792 0.1285 0.0874 -0.9792 0.1729 0.0877 -0.9792 0.1162 0.0889 -0.9792 0.1573 0.0890 -0.9792 0.1247 0.0879 -0.9792 0.1690 0.0880 -0.9792 0.1536 0.0873 -0.9792 0.1406 0.0886 -0.9792 0.1497 0.0877 -0.9792 0.1440 0.0882 -0.9792 0.1471 0.0880 -0.9792 0.1471 0.0880 -0.9792 0.1471 0.0880 -0.9792 0.1471 0.0880 -0.9792 0.1471 0.0880 -0.9792 0.1471 0.0880
T.Cf = Cf;
T.Nu = Nu;
T.Sh = Sh;
vars = T.Properties.VariableNames;
T = removevars(T,vars(startsWith(vars,'Var')));
writetable(T,filename,'WriteMode','overwritesheet')
% check the result:
T = 20×6 table
Rd A B Nu Cf Sh ____ ____ ____ _______ ________ ________ 0.5 0.1 0.1 0.13206 -0.97916 0.086996 1 0.1 0.1 0.17905 -0.97916 0.087231 0.5 0.2 0.1 0.12132 -0.97916 0.088354 1 0.2 0.1 0.16543 -0.97916 0.088372 0.5 0.1 0.2 0.12845 -0.97916 0.087412 1 0.1 0.2 0.17295 -0.97916 0.087693 0.5 0.2 0.2 0.1162 -0.97916 0.088937 1 0.2 0.2 0.1573 -0.97916 0.088983 0.5 0.15 0.15 0.12467 -0.97916 0.087907 1 0.15 0.15 0.16897 -0.97916 0.088049 0.75 0.1 0.15 0.15364 -0.97916 0.087309 0.75 0.2 0.15 0.14057 -0.97916 0.088615 0.75 0.15 0.1 0.14975 -0.97916 0.087723 0.75 0.15 0.2 0.14403 -0.97915 0.088241 0.75 0.15 0.15 0.14711 -0.97916 0.087962 0.75 0.15 0.15 0.14711 -0.97916 0.087962
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
MINATI PATRA le 15 Jan 2024
Modifié(e) : MINATI PATRA le 15 Jan 2024
@ Voss
I am astonished, how you are getting this level of ideas?
%% Sorry but another problem with an extendd form of this idea is unsolved in the following link

Connectez-vous pour commenter.

### Plus de réponses (1)

Ayush Modi le 14 Jan 2024
Hi Minati,
I ran the code and got the following error - Unrecognized function or variable 'A'.
Upon checking the code, I observed that the variable "A" is commented in the code.
Le = 1; K1 = 0.01; a1 = 0.1; a2 = 0.1; % Rd = 0.75; A = 0.15; B = 0.15; -- Original code
After correcting the code with the following changes, the code worked fine.
Le = 1; K1 = 0.01; a1 = 0.1; a2 = 0.1; Rd = 0.75; A = 0.15; B = 0.15;
Hope this helps!
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
MINATI PATRA le 15 Jan 2024
@ Dear Ayush
It has been efficiently solved following Voss. He is Awesome.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Spreadsheets dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by