Please this code says Error using plot. Vectors must be the same length. Error in untitled2 (line 8) plot(I,V,'0');

4 views (last 30 days)
clear all; close all; clc;
%%VCE vs. IC (Fig.3, 125oC, VGE=15V)
I=[10 20 30 30 40 50 60 70 80 90 100];
V=[1.5 1.9 2.2 2.5 2.77 3 3.25 3.5 3.72 3.95];
plot(I,V,'o');
x=10:100;
y=-7.9167*10^(-5)*x.^2 + 0.035236*x + 1.1958;
plot(I,V,'o',x,y);
%%Conduction Loss Calculation
Tj= 125; fsw=20000;
a=-7.9167*10^(-5);b=0.035236; c=1.1958;
I=40; M=0.5;
syms theta;
i=0;
j=0;
for M=0.2:0.05:0.8
j=j+i;
duty=0.5*0.5*M*sin(theta);
i=0;
for I=10:5:100
i=i+1;
F_cond=I*sin(theta)*(a*(I*sin(theta))^2+b*I*sin(theta)+c);
Cal_cond_loss(i,j)=double(int(duty*F_cond,theta,0,pi))/(2* pi);
end
end
surf(Cal_cond_loss); hold on; colorbar('Eastoutside');
axis([1 j 1 i 0 100]);
set(gca, 'XTick',1:4:13);
set(gca, 'YTick',1:6:19);

Accepted Answer

VBBV
VBBV on 7 Nov 2022
I=[10 20 30 30 40 50 60 70 80 90 100];
V=[1.5 1.9 2.2 2.5 2.77 3 3.25 3.5 3.72 3.95 4]; % this vector has less number of elements
V has only 10 elements
i=0;
j=0;
for M=0.2:0.05:0.8
j=j+1; % change it to 1 and try

More Answers (2)

Askic V
Askic V on 7 Nov 2022
It is because I has 11 elements and V has only 10 elements. Thy should have the same number of elements to plot them as (x,y) pairs.
  2 Comments
Awesome
Awesome on 7 Nov 2022
Index in position 2 is invalid. Array indices must be positive integers or logical values.
Error in untitled2 (line 28)
Cal_cond_loss(i,j)=double(int(duty*F_cond,theta,0,pi))/(2* pi);
Please help check this
>>

Sign in to comment.


salman
salman on 29 Jan 2024
z1=[2 1+7i; 8i 5+8i]
z1 =
2.0000 + 0.0000i 1.0000 + 7.0000i 0.0000 + 8.0000i 5.0000 + 8.0000i
z2=[1+5i 12+4i; 5i 3+13i]
z2 =
1.0000 + 5.0000i 12.0000 + 4.0000i 0.0000 + 5.0000i 3.0000 +13.0000i
real(z1)
ans = 2×2
2 1 0 5
real(z2)
ans = 2×2
1 12 0 3
imag(z1)
ans = 2×2
0 7 8 8
imag(z2)
ans = 2×2
5 4 5 13
real(z1+z2)
ans = 2×2
3 13 0 8
imag(z1+z2)
ans = 2×2
5 11 13 21
conj(z1+z2)
ans =
3.0000 - 5.0000i 13.0000 -11.0000i 0.0000 -13.0000i 8.0000 -21.0000i
Plot(z1+z2,'o')
Unrecognized function or variable 'Plot'.

Categories

Find more on Get Started with Symbolic Math Toolbox 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!