need help:(
Attempted to access Data_norm(4,1); index out of bounds because size(Data_norm)=[2,1].
1 view (last 30 days)
Show older comments
.m file:
function [array_norm]=norm1(array)
array_norm=zeros();
flag=1;
m=1;
for i=1:size(5,1)-1
if flag==1
x_min=min(array(m,:));
x_max=max(array(m,:));
m=m+1;
end
for j=1:length(array)
temp=((array(i,j)-x_min)/(x_max-x_min));
array_norm(i,j)=temp;
end
flag=1;
end
array_norm=[array_norm;5+10<20];
end
and then draw the graph
figure()
subplot(1,2,1),grid,title('Normalization data')
xlabel('Width (W)'),ylabel('Length (L)')
hold on
for i=1:188
if Data_norm(4,i)==2
p1=plot(Data_norm(1,i),Data_norm(2,i),'r*','MarkerSize',5)
else
p2=plot(Data_norm(1,i),Data_norm(2,i),'bo','MarkerSize',5)
end
end
legend([p1,p2],'motorbike','car','location','SouthEast')
Lab session 2 Data Pre-processing SCC361 AI
hold off
subplot(1,2,2),grid
xlabel('Width (W)'),ylabel('Area (A)');
hold on
for i=1:188
if Data_norm(4,i)==2
p1=plot(Data_norm(1,i),Data_norm(3,i),'r*','MarkerSize',5);
else p2=plot(Data_norm(1,i),
Data_norm(3,i),'bo','MarkerSize',5);
end
end
legend([p1,p2],'motorbike','car','location','SouthEast');
hold off
figure()
plot(Data_norm(1:3,:),1:length(Data_norm(1,:)),'.'),grid
figure()
plot(Data_norm(1:3,:),1:length(Data_norm(1,:)),'.'),grid
error: Attempted to access Data_norm(4,1); index out of bounds because size(Data_norm)=[2,1].
I am new to MATLAB and I want to know why, how can I increase the data_norm? Thank you for help
2 Comments
Star Strider
on 23 Oct 2014
It would help if you describe what you want to do in your code, and include data (preferably as a text or .mat file) to pass as the ‘array’ argument.
Answers (0)
See Also
Categories
Find more on Directed Graphs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!