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 件)

rose mary perumattil jose
rose mary perumattil jose 2018 年 8 月 9 日
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 ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by