Problems with cell array plotting

1 visualización (últimos 30 días)
Brendan Rapp
Brendan Rapp el 19 de Jun. de 2023
Comentada: Brendan Rapp el 29 de Jun. de 2023
Hello everybody,
I have a little issue with a cell array. I have to do lots of plots for my project. However, I worked with cells with 2 or with 3 columns and that worked out. Now, I have data with 4 columns and the way I used to do it does not work anymore. anyone an Idea?
clear all;
close all;
clc
%%labels['Ld-50%' 'Ld-45%' 'Ld-40%' 'Ld-35%' 'Ld-30%' 'Ld-25%' 'Ld-20%' 'Ld-15%' 'Ld-10%' 'Ld' 'Ld+10%' 'Ld+15%' 'Ld+20%' 'Ld+25%' 'Ld+30%' 'Ld+35%' 'Ld+40%' 'Ld+45%' 'Ld+50%'];
%%Second part for reading in multiple files
Drpm = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\rpm';
filesrpm = dir(fullfile(Drpm, '*.csv'));
Dtorquemech = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\meschanisches Moment';
filestorquemech = dir(fullfile(Dtorquemech, '*.csv'));
Dtorqueel = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\elektrisches Moment';
filestorqueel = dir(fullfile(Dtorqueel, '*.csv'));
Didg = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\id Gegenwart';
filesidg = dir(fullfile(Didg, '*.csv'));
Diqg = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\iq Gegenwart';
filesiqg = dir(fullfile(Diqg, '*.csv'));
Didz = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\id Zukunft';
filesidz = dir(fullfile(Didz, '*.csv'));
Diqz = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\iq Zukunft';
filesiqz = dir(fullfile(Diqz, '*.csv'));
Dcf = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\Cost function';
filescf = dir(fullfile(Dcf, '*.csv'));
Dcurrents = 'C:\Users\Brendan\OneDrive\Masterarbeit_prädiktive_Stromregler\Modelle\01_Parameter\01_Ld\a,b,c Ströme';
filescurrents = dir(fullfile(Dcurrents, '*.csv'));
for i = 1:19
%Drehzahl
fnmrpm = fullfile(Drpm,filesrpm(i).name);
datarpm{i} = readmatrix(fnmrpm);
yrpm = num2cell(datarpm, 1);
thelprpm = yrpm{1};
trpm = thelprpm{1}(:, 1);
%mechanisches Moment
fnmtorquemech = fullfile(Dtorquemech,filestorquemech(i).name);
datatorquemech{i} = readmatrix(fnmtorquemech);
ytorquemech = num2cell(datatorquemech, 1);
%elektrisches Moment
fnmtorqueel = fullfile(Dtorqueel,filestorqueel(i).name);
datatorqueel{i} = readmatrix(fnmtorqueel);
ytorqueel = num2cell(datatorqueel, 1);
%id Gegenwart
fnmidg = fullfile(Didg,filesidg(i).name);
dataidg{i} = readmatrix(fnmidg);
yidg = num2cell(dataidg, 1);
%iq Gegenwart
fnmiqg = fullfile(Diqg,filesiqg(i).name);
dataiqg{i} = readmatrix(fnmiqg);
yiqg = num2cell(dataiqg, 1);
%id Zukunft
fnmidz = fullfile(Didz,filesidz(i).name);
dataidz{i} = readmatrix(fnmidz);
yidz = num2cell(dataidz, 1);
%iq Zukunft
fnmiqz = fullfile(Diqz,filesiqz(i).name);
dataiqz{i} = readmatrix(fnmiqz);
yiqz = num2cell(dataiqz, 1);
%Cost function
fnmcf = fullfile(Dcf,filescf(i).name);
datacf{i} = readmatrix(fnmcf);
ycf = num2cell(datacf, 1);
%abc Ströme
fnmcurrents = fullfile(Dcurrents,filescurrents(i).name);
datacurrents{i} = readmatrix(fnmcurrents);
ycurrents = num2cell(datacurrents, 1);
end
for i=1:19
rpmc{i} = datarpm{i}(:, 2);
torquemechc{i} = datatorquemech{i}(:, 2);
torqueelc{i} = datatorqueel{i}(:, 2);
idgc{i} = dataidg{i}(:, 2);
iqgc{i} = dataiqg{i}(:, 2);
idzc{i} = dataidz{i}(:, 2);
iqzc{i} = dataiqz{i}(:, 2);
cfc{i} = datacf{i}(:, [2 3]);
currentsc = datacurrents{i}(:, [2 3 4]);
end
for i=1:19
rpm = rpmc{i};
thelp = yrpm{1,i};
trpm = thelp{1}(:, 1);
plot(trpm,rpm)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
torquemech = torquemechc{i};
thelptorquemech = ytorquemech{1,i};
ttorquemech = thelptorquemech{1}(:, 1);
plot(ttorquemech,torquemech)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
torqueel = torqueelc{i};
thelptorqueel = ytorqueel{1,i};
ttorqueel = thelptorqueel{1}(:, 1);
plot(ttorqueel,torqueel)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
idg = idgc{i};
thelpidg = yidg{1,i};
tidg = thelpidg{1}(:, 1);
plot(tidg,idg)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
iqg = iqgc{i};
thelpiqg = yiqg{1,i};
tiqg = thelpiqg{1}(:, 1);
plot(tiqg,iqg)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
idz = idzc{i};
thelpidz = yidz{1,i};
tidz = thelpidz{1}(:, 1);
plot(tidz,idz)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
iqz = iqzc{i};
thelpiqz = yiqz{1,i};
tiqz = thelpiqz{1}(:, 1);
plot(tiqz,iqz)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
cf = cfc{i};
thelpcf = ycf{1,i};
tcf = thelpcf{1}(:, 1);
plot(tcf,cf)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
figure
for i = 1:19
currents = currentsc{i};
thelpcurrents = ycurrents{1,i};
tcurrents = thelpcurrents{1}(:, 1);
plot(tcurrents,currents)
%legend('Ld-50%', 'Ld-45%', 'Ld-40%', 'Ld-35%', 'Ld-30%', 'Ld-25%', 'Ld-20%', 'Ld-15%', 'Ld-10%', 'Ld', 'Ld+10%', 'Ld+15%', 'Ld+20%', 'Ld+25%', 'Ld+30%', 'Ld+35%', 'Ld+40%', 'Ld+45%', 'Ld+50%')
hold all
end
  6 comentarios
Dyuman Joshi
Dyuman Joshi el 19 de Jun. de 2023
You are trying to access a double array via curly brackets, which is not possible. Use parenthesis to access elements of a double array.
%Example
y = magic(5)
y = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
y(7)
ans = 5
y{7}
Brace indexing is not supported for variables of this type.
Brendan Rapp
Brendan Rapp el 29 de Jun. de 2023
That helped thank you!

Iniciar sesión para comentar.

Respuestas (1)

Voss
Voss el 24 de Jun. de 2023
Change this:
currentsc = datacurrents{i}(:, [2 3 4]);
to this:
currentsc{i} = datacurrents{i}(:, [2 3 4]);

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by