How to plot only a few values ​​of a matrix?

I have two array of size 48000 1 and I would like to plot only values less than "X". I am new to matlab. Thanks and any help is validates.

 採用された回答

Marshall
Marshall 2013 年 6 月 6 日
編集済み: Marshall 2013 年 6 月 6 日

0 投票

If 'temp' is your array that is 48000x1 you can specify specific indices as follows:
temp(1:X, 1)
This will get rows in temp from 1 to 'X' in the first column. General form being:
temp(w:x, y:z)
This will return the values in temp from rows 'w' to 'x' and columns 'y' to 'z'.
To then plot simply:
plot(temp(1:X, 1))
Hope this helps!
//edit Just reread your question and interpreted it a completely different way. So in case the above doesn't help:
You could probably write a short little script to separate out the values of the array that are less than 'X' and plot a separate array.
Try something like this:
for i=1:length(myBigArray)
if (myBigArray(i) < 'X')
temp(i) = myBigArray(i);
end
end
plot(temp);
Not the prettiest, but I think it might do what you want. You might also find the matlab function 'find' useful for your application. This function can return the indices of your array that satisfy a condition: find(myBigArray < X)

3 件のコメント

Jadiel Silva
Jadiel Silva 2013 年 6 月 6 日
Hello Marshall
I think your second answer is that the best solution would give me, but I will explain a little clearer and if you can help me I appreciate it immensely. I have the matrix Lm and Wm together they form 2D coordinates of points for each coordinate and I plot a point, thus forming a large image with points. But there are some points that I did not want it to be plotted, for exeplo values less than 0.2800 which is contained in the matrix Lm and has its corresponding value in the matrix Wm.
Again I appreciate your help immensely.
Marshall
Marshall 2013 年 6 月 6 日
I see, sorry for misinterpreting you at first. I understand now.
Does something like this work for you? It will find all indices in Lm less than 0.28 and remove those indices from Lm and Wm. (Note that those values will be permanently removed from Lm and Wm).
index = find(Lm < 0.28)
Lm(index) = [];
Wm(index) = [];
plot(Lm, Wm);
Jadiel Silva
Jadiel Silva 2013 年 6 月 7 日
thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by