# Plotting one value from a vector

조회 수: 8 (최근 30일)
Gabriela 2023년 9월 15일
답변: Mathieu NOE 2023년 9월 15일
I have a file where they give me a vector with multiple measurements (the vector is 100x500). I need to plot only one of thoes measurements onto the graph but my code is plotting all of them since i don't know how to plot one. How can I plot only one? Thank you for the help! This is my code:
(figure #2 is where im having the problem)
clear;
clc;
t=linspace(0,500,numel(L.actual_ver));
Ensembl_avg=mean(L.ver);
figure(1);
plot(t,Ensembl_avg);
hold on;
plot(t,L.actual_ver);
grid on;
xlabel('Time');
ylabel('Ensemble Average and Actual Signal');
title('Ensemble Average and Actual Signal VS Time:');
figure(2);
plot(t,L.ver);
hold on;
plot(t,L.actual_ver);
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Image Analyst 2023년 9월 15일
That's not a 1-D vector, it's a 2-D matrix. Which value from the matrix do you want to plot? Try something like
plot(L.ver(row, column), 'b.', 'MarkerSize', 50);

댓글을 달려면 로그인하십시오.

### 답변 (1개)

Mathieu NOE 2023년 9월 15일
hello
simply change this
figure(2);
plot(t,L.ver);
into :
figure(2);
channel = 50; % pick value between 1 and 100
plot(t,L.ver(channel,:));
also I wondered if there is a small but in your time vector t
we know that you have 500 samples but when you write :
t=linspace(0,500,numel(L.actual_ver));
this means you have a time vector that goes from 0 to 500 with 500 samples so time increment is (500-0) / (500 -1 ) = 1.002
I just thought that maybe the time increment was 1 so I opted for this way of creating the time vector
t=(0:numel(L.actual_ver)-1);
forget this if I'm wrong
all the best
full code :
t=(0:numel(L.actual_ver)-1);
Ensembl_avg=mean(L.ver,1);
figure(1);
plot(t,Ensembl_avg);
hold on;
plot(t,L.actual_ver);
grid on;
xlabel('Time');
ylabel('Ensemble Average and Actual Signal');
title('Ensemble Average and Actual Signal VS Time:');
figure(2);
channel = 50; % pick value between 1 and 100
plot(t,L.ver(channel,:));
hold on;
plot(t,L.actual_ver);

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by