Extracting data from cell array: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side
Afficher commentaires plus anciens
Hi there, I have a 1*365 cell, in which it contains 365 3191*1 cells. I need to extract data (e.g., a GPS station data) from each 3191*1 cell.

By running the code (below), I always get 'Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.' Can anyone offer any suggestions? Thanks in advance.
clear all; clc;
loadf = 1;
files = dir('*.txt');
for i=1:length(files)
F = fullfile(files(i).name);
fid(i)=fopen(files(i).name);
files(i).values=textscan(fid(i), '%s','delimiter',',','HeaderLines',20,'MultipleDelimsAsOne',1);
end
for i = 1:length(files)
for v = 1:numel(files)
val(i) = files(v).values;
end
end
for k = 1:length(val)
WARK(i) = cell2mat(val{1,k}([2952:2963]));
end
Réponses (1)
Ameer Hamza
le 4 Déc 2020
Can you explain in which form do you want the output? The following show how you can extract those values and store them in a cell array
WARK = cell(size(val))
for k = 1:length(val)
WARK{k} = cell2mat(val{1,k}(2952:2963));
end
5 commentaires
Vicky Liu
le 4 Déc 2020
Ameer Hamza
le 4 Déc 2020
How are the indices decided? Are they also stored somewhere?
Vicky Liu
le 4 Déc 2020
Ameer Hamza
le 4 Déc 2020
Can you attach these variables in a .mat file. It will make it easier to suggest a solution.
Vicky Liu
le 4 Déc 2020
Catégories
En savoir plus sur String Parsing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





