plotting matrix verses vector

Good evening
I want to plot a frequency vector (x-axes) with a path loss matrix which is 16*16
I tried this but it gives me an error
figure(1);
plot(p.f,H(1,:),
p.f,H(2,:),
p.f,H(3,:),
p.f,H(4,:),
p.f,H(5,:),
p.f,H(6,:),
p.f,H(7,:),
p.f,H(8,:),
p.f,H(9,:),
p.f,H(10,:),
p.f,H(11,:),
p.f,H(12,:),
p.f,H(13,:),
p.f,H(14,:),
p.f,H(15,:),
p.f,H(16,:));

3 comentarios

Steven Lord
Steven Lord el 26 de Oct. de 2018
What is the full text (everything displayed in red) of the error message?
What do the following commands show?
sf = size(p.f)
cf = class(p.f)
sh = size(H)
ch = class(H)
Stephen23
Stephen23 el 26 de Oct. de 2018
You could just plot the whole matrix like this:
plot(p.f,H.')
Alice Faisal
Alice Faisal el 26 de Oct. de 2018
Vectors must be the same length.
It gives me this error now

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 26 de Oct. de 2018

0 votos

The easiest solution is likely:
plot(p.f, H)
If ‘H’ is a square matrix, and you want to transpose it, use:
plot(p.f, H.')
instead.

2 comentarios

Alice Faisal
Alice Faisal el 26 de Oct. de 2018
Vectors must be the same length.
It gives me this error now
Star Strider
Star Strider el 26 de Oct. de 2018
I assumed ‘p.f’ is a vector.
If it a matrix the same size as ‘H’, either of my plot calls will work:
p.f = rand(16);
H = rand(16, 16);
figure
plot(p.f, H)
If not, you will have to choose what vector in ‘p.f’ to plot with. The vector must have 16 elements to plot with your (16x16) matrix.

Iniciar sesión para comentar.

madhan ravi
madhan ravi el 26 de Oct. de 2018
Editada: madhan ravi el 26 de Oct. de 2018

0 votos

An example its possible using loop:
H=rand(16)
p.f = 1:16
figure(1);
for i = 1:length(H)
plot(p.f(1,:),H(i,:))
hold on
end

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 26 de Oct. de 2018

Editada:

el 26 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by