Problem - vectors must be the same size
显示 更早的评论
I have a function below that put 36 vectors on top of each other. I do this so I can plot it with another vector I3 from another function.
If I set the nr to smaller numbers up to 31 it works, but then I get the message:
Error using plot
Vectors must be the same length.
Error in PLOTTING (line 21)
plot(I3,D,'.')
Is there another way to put vectors on top of each other?
Thanks
Here is my function
function [D]=AH(nr,AAG,s)
for y=1:nr
xx=cell(length(AAG{y}),1);
for o=1:length(AAG{y})
xx{o} =[AAG{y}{o} zeros(1,s-length(AAG{y}{o}))];
end
for k1 = 1:length(AAG{y})
%
%
%
% %Histogram over all values
if k1==1
G(k1:length(xx{k1}))=xx{k1};
else
G((k1-1)*s+1:k1*s)=xx{k1};
% G=[G xx{k1}];
end
%
%
%Plotting inhabitants
% scatter(ones(1,numel(xx{k1}))*y, xx{k1},ones(1,numel(xx{k1}))*I{k1},'s','Linewidth',10)
end
if y==1
D1=G.';
end
if y==2
D2=G.';
end
if y==3
D3=G.';
end
if y==4
D4=G.';
end
if y==5
D5=G.';
end
if y==6
D6=G.';
end
if y==7
D7=G.';
end
if y==8
D8=G.';
end
if y==9
D9=G.';
end
if y==10
D10=G.';
end
if y==11
D11=G.';
end
if y==12
D12=G.';
end
if y==13
D13=G.';
end
if y==14
D14=G.';
end
if y==15
D15=G.';
end
if y==16
D16=G.';
end
if y==17
D17=G.';
end
if y==18
D18=G.';
end
if y==19
D19=G.';
end
if y==20
D20=G.';
end
if y==21
D21=G.';
end
if y==22
D22=G.';
end
if y==23
D23=G.';
end
if y==24
D24=G.';
end
if y==25
D25=G.';
end
if y==26
D26=G.';
end
if y==27
D27=G.';
end
if y==28
D28=G.';
end
if y==29
D29=G.';
end
if y==30
D30=G.';
end
if y==31
D31=G.';
end
if y==32
D32=G.';
end
if y==33
D33=G.';
end
if y==34
D34=G.';
end
if y==35
D35=G.';
end
if y==36
D36=G.';
end
end
D=[D1;D2;D3;D4;D5;D6;D7;D8;D9;D10;D11;D12;D13;D14;D15;D16;D17;D18;D19;D20;D21;D22;D23;D24;D25;D26;D27;D28;D29;D30;D31;D32;D33;D34;D35;D36];
end
The script is:
%PLOTTING
close all
clear
load AAI
load AAG
s=1000; %sample size
G=zeros(100000000,1);
I22=zeros(10000000,1);
nr=36;
[I3]=Inhabitants(AAI(1:nr),s);
[D]=AH(nr,AAG,s);
%D=[D1;D2;D3];
figure
HISS=histogram(nonzeros(D));
xlabel('Increase in %')
figure
plot(I3,D,'.')
ylim([0 30])
xlim([0 100])
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!