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 Center および File ExchangeWord games についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by