ploting data from the rearranged data in excel
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
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.
Respuesta aceptada
Mischa Kim
el 31 de En. de 2014
Editada: Mischa Kim
el 31 de En. de 2014
- 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
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
...
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!