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?

9 visualizaciones (últimos 30 días)
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)

Respuestas (1)

Image Analyst
Image Analyst el 9 de Feb. de 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 comentario
ABHISEK MOHANTY
ABHISEK MOHANTY el 9 de Feb. de 2015
Editada: ABHISEK MOHANTY el 9 de Feb. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by