Im trying to add only a few elements from 1 big array too a smaller array, im using a if statement to get the data i want, then im trying to add those can someone help :D
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
[~, ~, activeBatch] = xlsread('G:\Vision\Vision oversigt.xlsx','Color Management','Y3:Y966');
for i=1:numel(activeBatch)
if contains(activeBatch{i},'ActiveX VT_ERROR:')
activeBatch{i,2} = 0; %delete
else
Batct = activeBatch{i};
activeBatch{i,2} = 1;
end
0 Kommentare
Antworten (1)
Rohit Kulkarni
am 4 Sep. 2023
Hi Mark,
Based on my understanding, it seems like you are attempting to add specific elements from one array to another based on a certain condition. However, I am unable to fully comprehend your code. Here is an example that illustrates a similar condition:
In the example provided below, an element from “array1” will be added to “concatenatedArray” if it contains the substring "an". Conversely, if the element does not contain "an", an element from “array2” will be added.
%Sample arrays
array1 = ["apple", "banana", "orange"];
array2 = ["grape", "kiwi", "mango"];
% Initialize the concatenated array
concatenatedArray = [];
% Loop through the elements of array1
for i = 1:length(array1)
% Check if array1 element contains "an"
if contains(array1(i), "an")
% Concatenate the element from array1 to the concatenatedArray
concatenatedArray = [concatenatedArray, array1(i)];
else
% Concatenate the element from array2 to the concatenatedArray
concatenatedArray = [concatenatedArray, array2(i)];
end
end
% Display the concatenated array
disp(concatenatedArray);
You can modify the above code according to your specifications.
Also, it is recommended to use “readtable” instead of “xlsread” in your code.
Please refer to the documentation provided below for more information on the “readtable” function. https://in.mathworks.com/help/matlab/ref/readtable.html
Hope the example provided helps!
0 Kommentare
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!