Is it possible to convert a function containing a plot into c++ code?

3 views (last 30 days)
Valeria Leto
Valeria Leto on 23 Dec 2021
Hi! Is it possible to convert this function into c++? I would like to open a window in c++ that shows data as if I were in MATLAB.
%% INTERPOLAZIONE (distingue tratti rettilinei e curve e risoluzione impostabile)
function [Xq,Yq,Zq,Vq] = interpolazione(ampiezza,point_seabed_e,point_seabed_n,point_seabed_e_piu,point_seabed_n_piu,point_seabed_e_meno,point_seabed_n_meno,I,ris,metodo,mydir,folder,Namefile)
%% il comando griddata vuole come ingressi vettori colonne quindi trasformo le matrici di coordinate est e nord in vettori colonna
if(ampiezza==0)
points = [point_seabed_e(:),point_seabed_n(:),I(:)];
else
points = [point_seabed_e(:),point_seabed_n(:),I(:)
point_seabed_e_piu(:),point_seabed_n_piu(:),I(:)
point_seabed_e_meno(:),point_seabed_n_meno(:),I(:)];
end
%% Nuovi punti dove voglio valutare l'immagine
%calcolo i limiti entro cui fare l'interpolazione
% nord
Max_n = max(points(:,2));
Min_n = min(points(:,2));
v_sup=ceil(Max_n);
v_inf=floor(Min_n);
% est
Max_e = max(points(:,1));
Min_e = min(points(:,1));
u_sup=ceil(Max_e);
u_inf=floor(Min_e);
u=[u_inf:ris:u_sup];
v=[v_sup:-ris:v_inf];
[Xq,Yq] = meshgrid(u,v);
Zq=zeros(length(v),length(u));
%interpolazione
Vq = griddata(points(:,1),points(:,2),points(:,3),Xq,Yq,metodo);
% Plot immagine interpolata
close all
figure(1)
surf(Xq,Yq,Zq,Vq,'EdgeColor','none')
title(['Immagine interpolata con metodo ' metodo ' e risoluzione ' num2str(100*ris) ' cm'])
colormap gray
colorbar
caxis([0 1])
axis equal
xlabel('est (m)')
ylabel('nord (m)')
view(2)
[U,ia,ic] = unique([points(:,1) points(:,2)],'rows');
savefig(figure(1),fullfile(mydir,folder,Namefile),'compact');
end

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!

Translated by