- put a pause after the xlsread(); or
- instead of using xlsread() look in the file exchange for xlsread1(); or
- switch to readtable() instead of xlsread(). Note that if you switch to readtable() then you can probably use it or readmatrix() instead of the csvread().
How to get rid of The RPC server is unavailable Error?
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Susan
le 10 Juil 2020
Réponse apportée : Samuel Gray
le 26 Jan 2022
Hi everyone,
I have a main folder with 10 subfolders in it. Each subfolder has 200 subfolders within them. in each of these 200 subfolders, I have 4 .csv files. I created a loop that the code opens a subfolder, do what I want and then move to the next one as follows
D = 'C:\Users\....\Data\'
S1 = dir(fullfile(D,'*'));
N1 = setdiff({S1([S1.isdir]).name},{'.','..'});
A = {};
B = {};
C = {};
for kk = 1 : 10
kk
D1 = fullfile(D, N1{kk});
S2 = dir(fullfile(D1,'*'));
N2 = setdiff({S2([S2.isdir]).name},{'.','..'});
for ii = 1 : 200
ii
T1 = dir(fullfile(D1,N2{ii},'*'));
C = {T1(~[T1.isdir]).name};
for jj = 1 : numel(C)
if jj == 1
F = fullfile(D1,N2{ii},C{jj});
[n,~,~] = xlsread(F);
elseif jj == 2
F = fullfile(D1,N2{ii},C{jj});
m = csvread(F);
elseif jj == 3
F = fullfile(D1,N2{ii},C{jj});
p = csvread(F);
elseif jj == 4
F = fullfile(D1,N2{ii},C{jj});
q = csvread(F);
end
end
A{kk, ii} = complex(p, m);
B{kk, ii} = q(:,1) - q(1,1);
C{kk, ii} = n(2);
end
end
when I run the code, I've got the "RPC server is unavailable" error on kk=2, ii =21. However, when I check the code manualy for kk=2, ii =21 it works perfectly. Any idea how I can get rid of this error? How I can improve the code to run faster? Any input would be greatly appreciated.
0 commentaires
Réponse acceptée
Walter Roberson
le 10 Juil 2020
I can think of three potential solutions:
That is, I suspect that the connection to the excel server is not ready in time, so you either need to slow down access or use the excel server differently or avoid using the excel server.
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!