Matrix dimensions must agree error
1 回表示 (過去 30 日間)
古いコメントを表示
Hey guys.
I wanted to plot a square wave, but i got this error. can you please help me.
Ws=2*pi*60;
tetha=0;
t=0:0.0001:0.1;
v1=1:1:inf; % it can be v1=1:1:30
N=45;
I=10;
p=2;
K =(2*N*I)/(pi*p);
F1=(K.*0.95).*((1/2).*(cos(Ws.*t-tetha)+cos(Ws.*t+tetha))-cos(Ws.*t).*cos(v1.*tetha).*cos(v1.*120)+sqrt(3).*(sin(Ws.*t).*sin(v1.*tetha).*sin(v1.*120)));
subplot(2,1,1)
plot(F)
2 件のコメント
Muhammad Azrul Izmee
2022 年 1 月 22 日
Help! It shows the asterisk error(natrix dim must agree). And error for the line 31 which is C calculation. I hv tried many ways to do it
dn = [1:1:365]; A = 23.45 * sin((2*pi/365)*(dn + 284));
k = [0.5:0.5:2.5]; L = [0:20:80]; B = 15 * (12 - k); C = (sind(A) .* sind(L)) + (cosd(A) .* cosd(L) .* cosd(B));
D = asind(C);
plot(k,D),xlabel('Solar Time (Hour)'),ylabel('Solar Altitude (degree)') grid on
DGM
2022 年 1 月 22 日
The sizes of the vectors do not match, as the error says.
dn = 1:1:365; % 1x365
A = 23.45 * sin((2*pi/365)*(dn + 284)); % 1x365
k = 0.5:0.5:2.5; % 1x5
L = 0:20:80; % 1x5
B = 15 * (12 - k); % 1x5
C = (sind(A) .* sind(L)) + (cosd(A) .* cosd(L) .* cosd(B));
It's not readily obvious how you intend to make them match. What is the intended output size? Perhaps use linspace() to create the vectors of the desired length.
採用された回答
KSSV
2020 年 7 月 30 日
Ws=2*pi*60;
tetha=0;
t=0:0.0001:0.1;
v1=linspace(1,30,length(t)); % it can be v1=1:1:30
N=45;
I=10;
p=2;
K =(2*N*I)/(pi*p);
F1=(K.*0.95).*((1/2).*(cos(Ws.*t-tetha)+cos(Ws.*t+tetha))-cos(Ws.*t).*cos(v1.*tetha).*cos(v1.*120)+sqrt(3).*(sin(Ws.*t).*sin(v1.*tetha).*sin(v1.*120)));
subplot(2,1,1)
plot(t,F1)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!