How can I cancel coloumns of an array/table using a user prompt and then plot the data?

1 Ansicht (letzte 30 Tage)
Hey Everyone,
I have several data points. So basically i exported my data in excel sheets. I have 33 columns, and 30.000+rows. (i could not attach it to this question).
I want to use the last 720 points only. I managed to create a code for certain channels.
But I would like to have a user input,asking which channels the person want to use. Eg. 1,2,3 out of the 15 channels available, and then import those in a separate array and plot them in a scatter graph. But i don`t know how to create a code that allows it to be any number of channels and then plot them as well on the same graph. I have attached what I have already.
The time coloumns I want to cancel and the date coloumn too.
I dont know if i managed to ask this question in a sensible way. So basicaly i would like to get a user input . Eg. "which channels do you want to use?"
User: "1,2,6" or "1,14"
and then the program save those in a separate array and then plots the points the average of the selected coloumns on the same scatter graph. Thank you for all the help!

Antworten (1)

Anmol Dhiman
Anmol Dhiman am 13 Nov. 2019
As per my understanding of the attached code, to get multiple values in array, use ‘[ ]’ while entering the inputs using prompt as shown below.
prompt = 'Enter the values\n';
x = input(prompt);
x = unique(x); % to store unique values
disp(x)
% OutPut
Enter the values
[1 1 3 4]
1 3 4
To plot all the channels simultaneously, try the following in your code
x = -2:0;
plot(T.CH_14);
xlim([-2 0])
ylim([-0.4 0.4])
hold on % To store scatter plots simultaneously
for i =1: numel(x)
p = x(i);
if p>1 && p<=14 % check if p lies in the range of the channels
% write the if statements here from measurement_reader.m
end
end

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by