surfc function : plot goes wrong
Show older comments
Hello there,
I am trying to plot my datas with the 'surfc' function, and after struggling and tinking some vectors to give them the good size, I can run my code without any error, but the plots aren't what I excepted (see the photos linked to this post).
This is the code:
ColumnToKeep=7;
d=dir(fullfile('C:\Users\boulet\Documents\Recherche\2022\,'*.txt')); % use appropriate wild card name
fnameNew=fullfile('C:\Users\boulet\Documents\Recherche\2022\,'OutputNameOfChoice.txt');
nFiles=numel(d);
for i=1:nFiles
data=readmatrix(fullfile(d(i).folder,d(i).name));
if i==1, OutData=zeros(size(data,1),nFiles);end
OutData(:,i)=data(:,ColumnToKeep); %Sauvegarder dans la n-ième colonne
end
writematrix(OutData,fnameNew)
%This first part works extremely well, it creates the 'OutData'file, which
%is a 162x71 double
%%
dataup=OutData(1:81,:);
datadown=OutData(81:161,:);
Vgup=linspace(-40,40,1);
Vgup2=transpose(Vgup);
Vgup3=repmat(Vgup2,81,71);
Vgdown=linspace(40,-40,1);
Vgdown2=transpose(Vgdown);
Vgdown3=repmat(Vgdown2,81,71);
time=0:1:80;
time2=transpose(time);
time3=repelem(time2,1,71);
figure
surfc(time3,Vgup3,dataup);
title('Sweep up','FontSize',20),view([0 0 1]),xlabel('Time (s)','FontSize',20),ylabel('Vg (V)','FontSize',20)
set(gca,'FontSize',16)
shading flat
colorbar('FontSize',16)
figure
surfc(time3,Vgdown3,datadown);
set(gca,'FontSize',16)
shading flat
title('Sweep down','FontSize',20),view([0 0 1]),xlabel('Time (s)','FontSize',20),ylabel('Vg (V)','FontSize',20)
colorbar('FontSize',16)
I can't tell what is wrong ..
If some of you have any advise, I'd be grateful.
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots 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!