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 view (last 30 days)
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)

Answers (1)

Image Analyst
Image Analyst on 9 Feb 2015
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 Comment
ABHISEK MOHANTY
ABHISEK MOHANTY on 9 Feb 2015
Edited: ABHISEK MOHANTY on 9 Feb 2015
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.

Sign in to comment.

Categories

Find more on Word games 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!