i have 30,000 rand value that i want to separate 400 to 400...then i wanna plot them but the x axis should start at 0 not 400 or 800 or...any help please?

3 件のコメント

DGM
DGM 2022 年 12 月 7 日
編集済み: DGM 2022 年 12 月 7 日
What does "i want to separate 400 to 400" mean?
"x axis should start at 0 not 400 or 800 or..."
It would be clearer to say what both xlimits are. Are they [0 29999]? Are they [0 399]? Maybe [1 400]?
arian hoseini
arian hoseini 2022 年 12 月 7 日
yes sorry i meant i need the first 400 num of that matrix(30000) to be plot start from 1 to 400 next one should be 401 to 800 then...and i need to save these plot with saveas(gcf,[num2str(i),'.jpg']) and i need the first 400 num in a matrix then next one in another matrix...
arian hoseini
arian hoseini 2022 年 12 月 7 日
for the matrix lets say i have 10 num in a matrix but i want to change it into 10 matrices...
[1 2 3 4 5 6 7 8 9 10]
[1]
[2]
.
.
[10]

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

 採用された回答

Jonas
Jonas 2022 年 12 月 7 日

1 投票

you could split them into multiple 400x1 vectors by this
data=rand(30000,1);
data=reshape(data,400,1,[]);
size(data)
ans = 1×3
400 1 75
you can then get each vector using indexing data(:,:,idx)
for idx=1%:75 % commented out to avoid to much plotting here
plot(0:399,data(:,:,idx));
% saveas(gcf,[num2str(idx),'.jpg']);
end

11 件のコメント

arian hoseini
arian hoseini 2022 年 12 月 7 日
thank u sir it helped me alot but about the plot i want next plot to start from 401 and the next one start from 801 and....
Stephen23
Stephen23 2022 年 12 月 7 日
"...but about the plot i want next plot to start from 401 and the next one start from 801 and...."
That is what Jonas' code does.
DGM
DGM 2022 年 12 月 7 日
Are you saying that you want 75 individual plots? What are you going to do with them all?
arian hoseini
arian hoseini 2022 年 12 月 7 日
no every figure shows 0 to 400
arian hoseini
arian hoseini 2022 年 12 月 7 日
yes DGM i need 75 individual plots i wanna use them in ANN
DGM
DGM 2022 年 12 月 7 日
0:400 is 401 elements, not 400. If x is supposed to correspond to integer-valued indices of the data, then it's going to be 1:400 or 0:399
Also, how would you feed a figure to an NN? As an image? Why is plotting even necessary at all?
arian hoseini
arian hoseini 2022 年 12 月 7 日
編集済み: arian hoseini 2022 年 12 月 7 日
as an image and plot is not necessary but i wanna make sure that im doing it correctly ....i do it with python...just help me how to have 75 plot...jonas helped alot but the problem is every figure start at 0 to 399 i need them to be continued like second plot be 400 to 799 and....
Jonas
Jonas 2022 年 12 月 7 日
just change
plot(0:399,data(:,:,idx));
to
plot((0:399)+(idx-1)*400,data(:,:,idx));
arian hoseini
arian hoseini 2022 年 12 月 7 日
thank u sir...i learned so much...
DGM
DGM 2022 年 12 月 7 日
編集済み: DGM 2022 年 12 月 7 日
You can do that, but you'll have to figure out how you want the image shaped, whether you want the ticks plotted, etc.
npoints = 30000; % or some multiple of 400
blocklen = 400;
startidx = 0;
% generate x,y
x = startidx:startidx+npoints-1;
y = rand(npoints,1);
% reshape
x = reshape(x,blocklen,[]);
y = reshape(y,blocklen,[]);
% plot and capture
nframes = size(x,2);
allframes = cell(nframes,1);
for k = 1:nframes
plot(x(:,k),y(:,k))
allframes{k} = frame2im(getframe(gcf));
end
This will save all the frames in a cell array. Alternatively, you can write them using imwrite().
Note that as images, the details of the start/end indices is moot, since the ticks aren't going to show that detail well enough for anyone to tell. You could always try to enforce the exact axis limits, but it's still not going to help much.
% place this in the loop between plotting and capture
xlim(x([1 end],k))
ylim([0 1])
arian hoseini
arian hoseini 2022 年 12 月 7 日
thanks

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

製品

リリース

R2016b

タグ

質問済み:

2022 年 12 月 7 日

コメント済み:

2022 年 12 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by