add cell or struct as title matlab plot
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dion Theunissen
am 11 Feb. 2021
Beantwortet: Star Strider
am 11 Feb. 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 Kommentare
Akzeptierte Antwort
Star Strider
am 11 Feb. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!