add cell or struct as title matlab plot
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dion Theunissen
le 11 Fév 2021
Réponse apportée : Star Strider
le 11 Fév 2021
Hi,
See my script below, I need to add the changing variable 'num' as title name. How can i fix that?
for i = 3:3
num = subFolders(i).name
num2 = struct2cell(num)
folder = ['C:\Users\dit\Documents\MATLAB\RawData\',num]; f = dir(fullfile(folder,'*.csv')); g = numel(f);
figure
title('How can I add num here?')
for k = 1:g
filename = fullfile(f(k).folder, f(k).name);
CSVData = readmatrix(filename, 'Range', 1, 'Delimiter', ','); [filepath,name,ext] = fileparts(filename); indexCSV = [(0:size(CSVData,1)-1)' CSVData];
xC{k,1}=CSVData(:,7); yC{k,1}=CSVData(:,8); zC{k,1}=CSVData(:,9); radC{k,1}=CSVData(:,2)/2;
indexC =indexCSV(:,1); [valCL, idxCL] = max(indexC);
plot3(xC{k,1},yC{k,1},zC{k,1},'-b')
hold on
end
folder = ['C:\Users\dit\Documents\MATLAB\Centerlines_Python\',num]; f = dir(fullfile(folder,'*.txt')); g = numel(f)-1;
for i = 0:g
Ofilename = fullfile(f(i+1).folder, f(i+1).name);
DataText=load(Ofilename);
x = DataText(:,1); y = DataText(:,2); z = DataText(:,3);
plot3(x,y,z,'-')
hold on
end
pause
close
end
0 commentaires
Réponse acceptée
Star Strider
le 11 Fév 2021
Since ‘num’ should be a simple character vector (at least it is when I tested this in R2020b), one of these should work:
title(num) % Includes Extension
title(extractBefore(num,'.')) % Removes Extension
.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!