Matrix dimensions must agree error
Show older comments
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 Comments
Muhammad Azrul Izmee
on 22 Jan 2022
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
on 22 Jan 2022
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.
Accepted Answer
More Answers (0)
Categories
Find more on Subplots 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!