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
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???
  1 个评论
ABHISEK MOHANTY
ABHISEK MOHANTY 2015-2-9
编辑:ABHISEK MOHANTY 2015-2-9
i want to take range of n as 1 to 7 and d as 1 to 100 for atleast 1000 values and gets answers some how. can u help me? main part is the range n and d needs to work and get values for the [a], which will get answers for rest equations. i am new to matlab. so if there is any other way to write program, please say so.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Word games 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by