Solving a equation from excel.

4 views (last 30 days)
Hello everyone,
I am trying to solve a equation and integration from a excel data. But I am getting an error in solving the equation.
The equation is (according to excel namings): XD60^2+U_prime^2-{(V_prime^2+W_prime^2)/2}.
This equation i need to integrate. Can someone help me in solving this. I have tried using the following code is as follows
[num data raw] = xlsread('Matlab_trail.xlsx');
for i=1:size(num,2)
% Num{i} = num(:,i)(~isnan(num(:,i)));
Col = num(:,i);
Num{i} = Col(~isnan(Col));
end
A1 = pi*Num{1}.^2*1.225;
Q1 = A1.*Num{2}.^2;
Int1 = cumtrapz(A1, Num{2}.^2);
A2 = 2*pi*1.225*Num{3};
Q1 = Num{2}.^2+Num{4}.^2-{Num{6}.^2+Num{8}.^2}./2;
Int2 = cumtrapz(A2, Q1);
plot(Num{1}, Int1, 'linewidth', 2);
hold on
plot(num(:,1), Int2, 'linewidth', 2);
hold off

Accepted Answer

dpb
dpb on 19 Aug 2022
Going at it hard way...first, just read the data as a table and can keep the variables as identified already...
>> tTrail=readtable('Matlab_trail.xlsx');
>> head(tTrail,3)
ans =
3×8 table
R XD60 XD U_prime XD_1 V_prime XD_2 W_prime
__________ ______ _________ _______ _________ _______ __________ _______
0 2.6909 0 0.24286 0.0015318 0.18446 0.00030059 0.18852
0.00038442 2.6851 0.0040551 0.24391 0.005111 0.18542 0.0038698 0.18833
0.0017053 2.6794 0.0076322 0.24468 0.0086903 0.18591 0.0074389 0.18858
>>
Then, use MATLAB vector syntax...
tTrail.Eqn=tTrail.XD60.^2+U_prime.^2-(V_prime.^2+W_prime.^2)/2;
Follow on with the next steps as you know the values you're trying to compute better than we can read the (nonworking) code.
NOTA BENE:
The expression
tTrail.XD60.^2+U_prime.^2
can also be written as
hypot(tTrail.XD60,U_prime).^2
  3 Comments
dpb
dpb on 22 Aug 2022
Edited: dpb on 22 Aug 2022
What does the result of head(tTrail,3) like I showed above return? It worked as shown here with the sample file.
Post the code as you ran it and the error in context; SOMETHING is different, but we can't see what...
Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga on 22 Aug 2022
Hello @dpb
i have found an other way to do the equation. Thank you for the help.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!