Clear Filters
Clear Filters

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

1 view (last 30 days)
Так что нарисуйте диаграмму из таблицы данных
функция 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 Comments
Michael Madelaire
Michael Madelaire on 30 Dec 2018
It is hard to follow when it is not in English, but is there any reason why you are not using saveas(fig, filename)?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 30 Dec 2018
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 Comments
Walter Roberson
Walter Roberson on 1 Jan 2019
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!