필터 지우기
필터 지우기

getting x and y values and writing them

조회 수: 1 (최근 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 CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by