MATLAB Answers

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

3 views (last 30 days)
Safa Sharif
Safa Sharif on 28 Jul 2021
Edited: Yongjian Feng on 29 Jul 2021
Hi, Im trying to get matlab to read my excel file but it keeps coming up with the above error message. Not sure how to recitfy it, please help!

Answers (2)

Yongjian Feng
Yongjian Feng on 28 Jul 2021
Try to initialize Y first?
Y = zeros(size_determined_by_your_Data, 6);
  2 Comments
Yongjian Feng
Yongjian Feng on 29 Jul 2021
Note that log(Data(:,6)) has the same size of Data(:, 6). But diff(log(Data(:, 6))) has one less. If your Data(:, 6) has size of n, then diff(log(Data(:, 6))) has size of n-1. Most likely the error is caused by this difference.
In other words, your Y shall be initialized with this in mind.

Sign in to comment.


VBBV
VBBV on 29 Jul 2021
Use gradient function instead of diff
%if true
Y(:,1) = 100*gradient(log(Data(:,6)));

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by