ploting data from the rearranged data in excel

Hi all, I have been working on my problem for days and days, and I just can not fix it.
I have my data in the attached excel file, I am stock by transferring the data. For the plot, I want X as A4:A43. matrix 'data' has been defined to collect the data.I just add these code to explain how I want the data stored in 'data'.
data=zeros(40,40);
X=xlsread('F:\RA\Parallel\Parallel.xls','Data','A4:A43');
Y=(1:40)';
%adder=39;
data(:,1)=xlsread('F:\Parallel\Parallel.xls','Data','C4:C43');
data(:,2)=xlsread('F:\Parallel\Parallel.xls','Data','C44:C83');
data(:,3)=xlsread('F:\Parallel\Parallel.xls','Data','C84:C123');
data(:,4)=xlsread('F:\Parallel\Parallel.xls','Data','C124:C163');
data(:,5)=xlsread('F:\Parallel\Parallel.xls','Data','C164:C203');
data(:,6)=xlsread('F:\Parallel\Parallel.xls','Data','C204:C243');
data(:,7)=xlsread('F:\Parallel\Parallel.xls','Data','C244:C283');
data(:,8)=xlsread('F:\Parallel\Parallel.xls','Data','C284:C323');
data(:,9)=xlsread('F:\Parallel\Parallel.xls','Data','C324:C363');
data(:,10)=xlsread('F:\Parallel\Parallel.xls','Data','C364:C403');
.
.
.
data(:,37)=xlsread('F:\Parallel\Parallel.xls','Data','C1444:C1483');
data(:,38)=xlsread('F:\Parallel\Parallel.xls','Data','C1484:C1523');
data(:,39)=xlsread('F:\Parallel\Parallel.xls','Data','C1524:C1563');
data(:,40)=xlsread('F:\Parallel\Parallel.xls','Data','C1564:C1603');
I want to do it in loops for later on if I add more data, but I cant make it right!!These are my new codes:
clear all
clc
format bank
data=zeros(40,40);
X=xlsread('F:\RA\Parallel\Parallel.xls','Data','A4:A43');
Y=(1:40)';
% adder=39;
% cc1=4;
% cc2=43;
for r=1:40
for c=1:40
for counter=4:43
data(c,r)=xlsread('F:\RA\Parallel\Parallel.xls','Data',['C' num2str(counter)]);
c=c+1;
end
r=r+1;
counter=counter+1;
end
colormap(hsv(16));
%colormap(hot(256));
%figure,surf(X,Y,data,'FaceColor','EdgeColor','FaceLighting');
surf(X,Y,data,'FaceColor','interp','FaceLighting','phong');
set(gca,'ZDir','reverse');
view(0,90);axis([0 15.8 1 40 -inf inf])
camlight right;
lighting phong;
%colorbar;
shading interp
end
I appreciate your help. Thank you.
Regards, S :-)

2 comentarios

dpb
dpb el 31 de En. de 2014
More useful would be what is the actual problem you're running into and any error messages, etc., on specific line(s) of code.
S
S el 31 de En. de 2014
Thanks for your reply and comment. I'll try to apply it.

Iniciar sesión para comentar.

 Respuesta aceptada

Mischa Kim
Mischa Kim el 31 de En. de 2014
Editada: Mischa Kim el 31 de En. de 2014

0 votos

  • First, don't increment loop indices (e.g. c). This is done automatically.
  • In the inner loop you keep overwriting data(c,r) with new data.
  • Lastly, why don't you use just one loop where you write to data(:,ii) (I am just using ii as my running loop index) like you have shown in your code all the way on the top?

3 comentarios

S
S el 31 de En. de 2014
Thanks for your reply Mischa Kim .
I increment c in the inner loop to over come the overwriting. I'll think about ur third comment.
Mischa Kim
Mischa Kim el 31 de En. de 2014
Editada: Mischa Kim el 31 de En. de 2014
Something like:
...
for ii = 1:40
low_ind = 4 + 40*(ii - 1);
high_ind = low_ind + 39;
table_ind = strcat('C', num2str(low_ind), ':C', num2str(high_ind));
data(:,ii) = xlsread('F:\Parallel\Parallel.xls','Data',table_ind);
end
...
That's it. Thanks.Instead of having the following line:
table_ind = strcat('C', num2str(low_ind), ':C', num2str(high_ind));
I was trying
xlsread('F:\Parallel\Parallel.xls','Data',['C', num2str(low_ind), :'C', num2str(high_ind)]
It did not work. I'll try the rest myself. Thank you again. I learned a new command :)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.

Preguntada:

S
S
el 31 de En. de 2014

Comentada:

S
S
el 31 de En. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by