read a column from excel sheet to array in matlab , perform operations , plot graph , write the result in successive column in Excel

first, I must express the elements in column 2 (the solar altitude) and 3 (the solar azimuth) as 2 arrays say array 1 and array 2. The number of elements (i.e the array size) of array 1 and array 2 are equal . However the size changes in each sheet of the excel file.
Secondly, I must create 2 new arrays say array 3 and array 4 with the same array size as the former arrays . Array 3 subtracts each element of array 1 from 90 . Array 4 simply copies the elements of Array 2.
Thirdly I must have 2 graphs ploted against their indices .
Finally , write the elements orray 3 and 4 in the columns adjacent to array 1 and 2 in the excel sheet.
When I excecute my code (given below), I get the below error : Index exceeds array bounds.
Shall be grateful if you have a look at my code snippet and let me know where am I going wrong ?
clc; clear all; daynumber = menu('Choose a Day', 'Day 1', 'Day 2', 'Day 3', 'Day 4'); switch (daynumber) case 1 inputA= xlsread('info.xlsx',1,'B3:B18'); alpha = xlsread('info.xlsx',1,'C3:C18'); isrow(inputA); beta(16:1)=90; gamma(16:1)=0; for i=16:1 gamma=inputA(i); beta=beta(i)-alpha(i); end
subplot(2,2,1)
plot (i,beta(i));
subplot(2,2,2);
plot (i,gamma(i));

 채택된 답변

madhan ravi
madhan ravi 2018년 8월 6일
편집: madhan ravi 2018년 8월 6일
hi this was your fault:
instead of:
gamma=inputA(i);
beta=beta(i)-alpha(i);
should be:
gamma(i)=inputA(i);
beta(i)=beta(i)-alpha(i);
Also:
for i=1:16

추가 답변 (1개)

Hello Madhan
thank you for helping me fix the code. It is working fine I was wondering how can I get 4 equations in one graph.
Looking forward for your valuable tips .
sincerely Rose Mary

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by