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
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Ameer Hamza
el 4 de Dic. de 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 comentarios
Ameer Hamza
el 4 de Dic. de 2020
Can you attach these variables in a .mat file. It will make it easier to suggest a solution.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!