Arrays have incompatible sizes for this operation.
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
y=4;
x=1;
k=y/x;
h=100;
Amax=10;
A=0:0.1:10;
a=2*x*pi*y.^-1;
i=0:h^-1:y;
B_i=floor(i+h^(-1));
f=48000;
F=f/k;
Eq=floor(A.*sin(a.*floor(B_i)+0.5))-A.*sin(a.*floor(B_i));
En=1/(12^(0.5));
Eqef=sqrt(sum(Eq.^2)./(h*y));
Kg=(Eqef.*100*sqrt(2))./A;
Kn=(En*100*sqrt(2))./A;
figure('Name','16','NumberTitle','off');
plot(A,Kg);
ylim([0,150]);
grid on;
hold on;
plot(A,Kn);
xlabel('A');
legend('Kg(A)','Kn(A)');
matlab gives an error:
Arrays have incompatible sizes for this operation.
Error in untitled2 (line 518)
Eq = floor (A. * sin (a. * Floor (B_i) +0.5)) - A. * sin (a. * Floor (B_i));
how to fix?
2 Kommentare
H R
am 9 Nov. 2021
The size of A is 1 by 101 while the size of B_i is 1 by 401. You should change A to be the same size as B_i.
Antworten (1)
Sudharsana Iyengar
am 9 Nov. 2021
Hi in your program you have A which is size 100 and B that is size 400. Thats is why this issue. Change your program to this.
y=4;
x=1;
k=y/x;
h=100;
Amax=10;
A=0:0.1:10;
a=2*x*pi*y.^-1;
i=0:h:y;% I removed h^-1 here.
B_i=floor(i+h^(-1));
f=48000;
F=f/k;
Eq=floor(A.*sin(a.*floor(B_i)+0.5))-A.*sin(a.*floor(B_i));
En=1/(12^(0.5));
Eqef=sqrt(sum(Eq.^2)./(h*y));
Kg=(Eqef.*100*sqrt(2))./A;
Kn=(En*100*sqrt(2))./A;
figure('Name','16','NumberTitle','off');
plot(A,Kg);
ylim([0,150]);
grid on;
hold on;
plot(A,Kn);
xlabel('A');
legend('Kg(A)','Kn(A)');
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!