# basic matrix creation question

2 visualizzazioni (ultimi 30 giorni)
Tom il 1 Nov 2012
Can anyone help me change this code so that I get r_n in one line rather than 7? Many thanks
clear all; close all;
inc = 180;
N = 6;
thetaDeg(91:180) = linspace(0,89,90); %covering from 270-360 & 0-90
r = 100;
d = 0.2;
n = linspace(1,N,N)';
x_n = n.*0;
y_n = ((N - (2*n - 1))./2).*d;
r_1 = sqrt((x_R - x_n(1)).^2 + (y_R - y_n(1)).^2);
r_2 = sqrt((x_R - x_n(2)).^2 + (y_R - y_n(2)).^2);
r_3 = sqrt((x_R - x_n(3)).^2 + (y_R - y_n(3)).^2);
r_4 = sqrt((x_R - x_n(4)).^2 + (y_R - y_n(4)).^2);
r_5 = sqrt((x_R - x_n(5)).^2 + (y_R - y_n(5)).^2);
r_6 = sqrt((x_R - x_n(6)).^2 + (y_R - y_n(6)).^2);
r_n = [r_1 r_2 r_3 r_4 r_5 r_6];
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Chris A il 1 Nov 2012
Try changing the last line to
r_n = [r_1' r_2' r_3' r_4' r_5' r_6'];
##### 1 CommentoMostra NessunoNascondi Nessuno
Tom il 2 Nov 2012
many thanks

Accedi per commentare.

### Più risposte (1)

Tom il 1 Nov 2012
Think I did it: -
clear all; close all;
inc = 180;
N = 6;
thetaDeg(91:180) = linspace(0,89,90); %covering from 270-360 & 0-90
r = 0.5; %distance of receiver from source in m
d = 0.2;
n = linspace(1,N,N)';
x_n = n.*0;
y_n = ((N - (2*n - 1))./2).*d;
r_n = zeros(N,inc);
for j = 1:N;
r_n(j,:)= sqrt((x_R - x_n(j)).^2 + (y_R - y_n(j)).^2);
end
Not sure though
##### 0 CommentiMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Just for fun in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by