getting x and y values and writing them

3 ビュー (過去 30 日間)
Mohamed Turkmani
Mohamed Turkmani 2022 年 8 月 16 日
コメント済み: Mohamed Turkmani 2022 年 8 月 16 日
hi, i have created a user interface that gets sampling frequency and frequency from the user and plots it by the following code:
function pushbutton1_Callback(hObject, eventdata, handles)
sample = str2double(get(handles.edit1,'string'));
freq = str2double(get(handles.edit3,'string'));
if freq ~= 1000 && freq ~= 2000 && freq ~= 1600 && freq ~= 4000
f = msgbox("Enter values within the frequency rules");
end
nCyl = 1;
t=0:(1/sample):(nCyl/freq);
x=sin(2*pi*freq*t);
axes(handles.axes1);
plot(t,x);
my next step is to get the x and t values from the graph and write them all in a text file or a message text, how can i get the values of x and y that are plotted in the graph?

採用された回答

KSSV
KSSV 2022 年 8 月 16 日
編集済み: KSSV 2022 年 8 月 16 日
Already you have data in hand. If you want to write that into a file use:
data = [t(:) x(:)] ;
writematrix(data,'data.txt') ;
If you want to extract data from figure and write:
a = get(gca,'Children');
xdata = get(a, 'XData');
ydata = get(a, 'YData');
data = [xdata(:) ydata(:)] ;
writematrix(data,'data.txt') ;
  3 件のコメント
KSSV
KSSV 2022 年 8 月 16 日
Edited the code.
Mohamed Turkmani
Mohamed Turkmani 2022 年 8 月 16 日
thanks <3

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by