Change the value in multiple text file?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I want change several value on my text file and i'm doing it manually. Is there a faster way to change a value in a multiple text file? All my text file have same matrix dimension.
Here are my example code that i do manually:
ZEE=xlsread('zee.xlsx','Area','B2:MP138');
ZEE=ZEE';
A=load('daya50MW.txt');
B=load('dayaelninoMW.txt');
for i=1:353
for j=1:137
if (ZEE(i,j) == 1)
daya50zee(i,j)=A(i,j);
else
daya50zee(i,j)=NaN;
end
end
end
for i=1:353
for j=1:137
if (ZEE(i,j) == 1)
dayaelninozee(i,j)=B(i,j);
else
dayaelninozee(i,j)=NaN;
end
end
end
Thank you
0 commentaires
Réponses (1)
KSSV
le 26 Juil 2021
You need not to take a loop, you can straight away use the logical indexing.
ZEE=xlsread('zee.xlsx','Area','B2:MP138');
ZEE=ZEE';
A=load('daya50MW.txt');
B=load('dayaelninoMW.txt');
daya50zee = NaN(size(A)) ;
dayaelninozee = NaN(size(A)) ;
daya50zee(ZEE == 1) = A(ZEE == 1) ;
dayaelninozee(ZEE == 1) = B(ZEE == 1) ;
0 commentaires
Voir également
Catégories
En savoir plus sur Data Import and Export 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!