help me.. how to fix this error. and run this prog. i need to put 2 variables in equations and get answers. so i took a range and a random number generater. is there any other way?
1 次查看(过去 30 天)
显示 更早的评论
clc
clear all
n=[1:.001:7];
d=rand(1000,1);
%display(n)
[a]=d*n;
% display([a])
[p]= (2*pi*[a]*cos(45))/300;
%display([p])
[A]=cos(p);
%display([A])
[B]=(1i.*sin(p)/n);
%display([B])
[C]=1i.*n.*sin(p);
%display([C])
[D]=cos(p);
%display([D])
%Reflection coefficient
[r]=real((n(1).*[A]+n(1).*n(3).*[B]+[C]-n(3).*[D])./(n(1).*[A]+n(1).*n(3).*[B]+[C]+n(3).*[D]));
%display ([r])
%[t]=(2.*n(1))./(n(1).*[A]+n(1).*n(3).*[B]+[C]+n(3).*[D]);
%display([t])
f=([r].^2)*100;
display(f)
回答(1 个)
Image Analyst
2015-2-9
In the line:
[C]=1i.*n.*sin(p);
n is 1-by-6001 and sin(p) is 1000-by-6001. To use .* the arrays must be the same size. I didn't delve into the code so I don't know what your intent here is. Maybe you want * instead of .* to do a matrix multiplication???
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!