I write a code to read and write in excel format.

1 view (last 30 days)
I write a code to read and write in excel format. The code was initially working perfectly. For the past two days when i run the code, it only show busy throughout without end and it does not display output (write). I need help. This is the code
This code sorts satellite data for Dr. Emmanuel
clear all;
clc;
if exist('result.xlsx','file')==2
delete('result.xlsx');
end
[loc1,loc2,~] = xlsread('locality.xlsx');
x = xlsread('satdata.xlsx');
for i = 1:length(loc2)
cc1 = strcat('A',int2str(i+1));
cc2 = strcat('B',int2str(i+1));
rloc = loc2{i,1};
xlswrite('result.xlsx',{rloc},1,cc1)
for j = 2:x(end,1)
[r1,c1] = find(x(:,2)==loc1(i,1));
[r2,c2] = find(x(1,:)==loc1(i,2));
p = x(r1,c2)';
end
xlswrite('result.xlsx',p,1,cc2)
end

Answers (1)

Geoff Hayes
Geoff Hayes on 18 Apr 2015
isreal - see the link debugging in MATLAB for ideas and instructions on how to step through your code and observe what is happening at each line. For example, if you put a breakpoint at the line clear all and then run the code, the debugger will pause at this line and you will be able to step over each line and observe certain aspects of your program. For example, after you have stepped over the line
[loc1,loc2,~] = xlsread('locality.xlsx');
what is the length of loc2 since this is used in your outer for loop? And when you have stepped over the line
x = xlsread('satdata.xlsx');
what is x(end,1) since this is used in your inner for loop? Are both of these numbers what you expect? If so, then perhaps there is a problem with the first or second xlswrite (maybe you are having trouble writing to file?). But at least with the debugger, you will be able to determine where in or why your code is getting stuck.

Tags

Community Treasure Hunt

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

Start Hunting!