Why, after compiling the program, the graphics are not saved in the selected folder?

1 次查看(过去 30 天)
Так что нарисуйте диаграмму из таблицы данных
функция pushbutton7_Callback (hObject, eventdata, дескрипторы)
глобальные N2s;
глобальные N3s;
глобальный Dpr2;
глобальный Dmin2;
глобальный D3m;
глобальный D3;
глобальный а;
глобальный б;
глобальный с;
глобальный d;
глобальный е;
глобальный f;
глобальный г;
глобальный х;
глобальный у;
глобальный р;
а = N3s;
B = N2s;
с = Dmin2;
д = DPR2;
е = D3M;
F = D3;
х = [0 бб 0];
у = [ccdd];
% лестницы (у, х)
r = [0 aa 0];
р = [Eeff];
% лестницы (р, ​​г)
plot (handles.axes2, y, x, p, r);
title (handles.axes2, 'Зависимое количество СН от дальности до цели' )
xlabel (handles.axes2, 'Дальность, км' );
ylabel (handles.axes2, 'Количество СН' );
Так что сохраните график
Функция uipushtool3_ClickedCallback (hObject, eventdata, дескрипторы)
[filename, pathname, indx] = uiputfile ( 'Зав. количество СН от дальности rez_1.jpeg' );
path_file = FullFile (путь, имя файла)
fid = fopen (path_file, 'w' );
если фид == -1
ошибка ( «Файл не открыт» );
конец
figure_image = getframe (handles.axes2);
imwrite (chart_image.CData, 'Зав. количество СН от дальности rez_1.jpeg' , 'jpeg' );
  3 个评论
Michael Madelaire
Michael Madelaire 2018-12-30
It is hard to follow when it is not in English, but is there any reason why you are not using saveas(fig, filename)?

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2018-12-30
You, for some reason, have called fopen(). So the file is open and locked when you try to call imwrite(). Therefore imwrite() will fail. You do not need to call fopen(). Don't do that.
Try this:
[baseFileName, folder] = uiputfile ( 'Зав. количество СН от дальности rez_1.jpeg' );
fullFileName = fullfile (folder, baseFileName)
saveas (handles.axes2, fullFileName);
  5 个评论
Walter Roberson
Walter Roberson 2019-1-1
When passed an axes, export_fig creates a new figure without menus and so on, and copies the given axes into the figure, and then saves the figure (because there are direct operations for saving figures.) This used to be required. Recently saveas() was improved to be able to save an axes directly.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by