Automatic building of an array
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
surendra kumar Aralapura mariyappa
le 28 Juin 2019
Commenté : surendra kumar Aralapura mariyappa
le 1 Juil 2019
Hey all,
Below is my function. I need to build the array automatically for the user input.
function suri1(Measuring_Data(:,7))
%User input
X = {1, 2,'Node1'; 3, 4, 'Node2'; 5, 6, 'Node3'}; % different for different users
n = 10;
d_T= 1 ;
t = 200;
S = load('Measuring_Data.mat');
f = 0:d_T:(t-1)*d_T;
p = cell2mat(X(:,1));
q = cell2mat(X(:,2));
disp(p);
disp(q);
T_Vorgabe = zeros(1,length(f)); % Row vector
for plotnumber = 1:n
c = find(p == plotnumber,1);
if ~isempty(c)
c = plotnumber;
for plotnumber1 = 1:n
c1 = find(q == plotnumber1,1);
if ~isempty(c1)
c1 = plotnumber1;
T_Vorgabe{c}(1,:) = S(c1,1); % May be worng syntax , All the values of the measuring data should be copied to T_Vorgabe as a row %vector or row cell array, c is the user input number to build the vector or cell array of different names
end
end
end
end
figure
hold('on')
for plotnumber2 = 1:n
c2 = find(p == plotnumber,1)
if ~isempty(c2)
c2 = plotnumber;
plot(f(1:15:end)/200, T_Vorgabe{c2}); % Slover should plot all the values of T_Vorgabe(row vector or row cell array.
end
end
end
Here T_Vorgabe{c2} will be cell array. Now while plotting the T_Vorgabe solver should get the all the values stored from the respective cell arrayT_Vorgabe{c2}.
My questions are,
How to make T_Vorgabe as a row vector, or row cell array of different names according to user input?
Like below
T_Vorgabe{1}=[1,2,3,...,2920]
T_Vorgabe{2}=[2921,2922,2923,...,5840] etc
Any suggestions and answers are most welcomed.
Thanks in advance
6 commentaires
surendra kumar Aralapura mariyappa
le 28 Juin 2019
Modifié(e) : surendra kumar Aralapura mariyappa
le 28 Juin 2019
Réponse acceptée
Bob Thompson
le 28 Juin 2019
'T_Vorgabe{c}(1,:) = S(c1,1);
I just need to know whether it is correct or not!. '
As I mentioned before, the concept is sound, and it should produce something like what you are looking for. I cannot tell you if it is 'correct' because minor adjustments may be needed to personalize the code to your specific dataset. I suspect this line will not actually have to be changed, but perhaps your definition of c and c1 will need to be changed. That is something you will have to tackle though when you have an actual sample of data to work with. That's just how debugging works.
'Second question is How to access the indicies of element of cell array?'
For information on how to work with cell indices I recommend this link. If you still need additional help, please be more specific.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!