How to remove NaN from data read from excel?

4 Ansichten (letzte 30 Tage)
Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga am 14 Jul. 2022
Hello all,
I am trying to solve a simple equation in matlab from the excel data. But I am getting NaN values as the data in the excel is not same in every row. How can i remove the NaN values? Please help me.
My code:
Z = readtable('Turbint_Kwsst.xlsx') ;
data = table2array(Z);
A = sqrt((2/3).*data(:,5));
O = A./data(:,4);
subplot(4,2,1)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,3), abs(O), 'linewidth', 2);
hold off
legend('Panchapaksan data-{u\prime}/U_s', 'RSM', 'Location', 'northeastoutside');
xlabel('r/L_u');
ylabel('{u\prime}/U_s');
title('At X/D = 50')
C = sqrt((2/3).*data(:,8));
Q = C./data(:,7);
subplot(4,2,2)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,6), abs(Q), 'linewidth', 2);
hold off
legend('Panchapaksan data-{u\prime}/U_s', 'RSM', 'Location', 'northeastoutside');
xlabel('r/L_u');
ylabel('{u\prime}/U_s');
title('At X/D = 60')
E = sqrt((2/3).*data(:,11));
S = E./data(:,10);
subplot(4,2,3)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,9), abs(S), 'linewidth', 2);
hold off
legend('Panchapaksan data-{u\prime}/U_s', 'RSM', 'Location', 'northeastoutside');
xlabel('r/L_u');
ylabel('{u\prime}/U_s');
title('At X/D = 70')
G = sqrt((2/3).*data(:,14));
U = G./data(:,13);
subplot(4,2,4)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,12), abs(U), 'linewidth', 2);
hold off
legend('Panchapaksan data-{u\prime}/U_s', 'RSM', 'Location', 'northeastoutside');
xlabel('r/L_u');
ylabel('{u\prime}/U_s');
title('At X/D = 80')
H = sqrt((2/3).*data(:,17));
V = H./data(:,16);
subplot(4,2,5)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,15), abs(V), 'linewidth', 2);
hold off
legend('Panchapaksan data-{u\prime}/U_s', 'RSM', 'Location', 'northeastoutside');
xlabel('r/L_u');
ylabel('{u\prime}/U_s');
title('At X/D = 90')
I = sqrt((2/3).*data(:,20));
W = I./data(:,19);
subplot(4,2,6)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,18), abs(W), 'linewidth', 2);
hold off
legend('Panchapaksan data-{u\prime}/U_s', 'RSM', 'Location', 'northeastoutside');
xlabel('r/L_u');
ylabel('{u\prime}/U_s');
title('At X/D = 100')
J = sqrt((2/3).*data(:,23));
X = J./data(:,22);
subplot(4,2,7)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,21), abs(X), 'linewidth', 2);
hold off
legend('Panchapaksan data-{u\prime}/U_s', 'RSM', 'Location', 'northeastoutside');
xlabel('r/L_u');
ylabel('{u\prime}/U_s');
title('At X/D = 110')
J = sqrt((2/3).*data(:,26));
X = J./data(:,25);
subplot(4,2,8)
plot(data(:,1), data(:,2), 'linewidth', 2);
hold on
plot(data(:,24), abs(X), 'linewidth', 2);
hold off
  8 Kommentare
Dyuman Joshi
Dyuman Joshi am 14 Jul. 2022
You can select a certain range, but if there is no data in a particular excel cell of your range, it will read it as NaN.
Otherwise you can read each column into a variable but then again, how will you perform operations if the columns don't have the same size?
Vishnuvardhan Naidu Tanga
Vishnuvardhan Naidu Tanga am 14 Jul. 2022
Hello I have found my desired solution. Thank you for your response. @Dyuman Joshi and @KSSV

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by