Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
How to make this code as a function?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi
I want to make the following code as a function. I want to call this code as function in another code to get the 'T' values.
[T_20]=xlsread('20.xlsx','sheet2','C2:C2243')
[alpha_20]=xlsread('20.xlsx','sheet2','F2:F12243')
for i=1:8
x(1)=0.1
x(2)=0.2
x(i+1)=x(i)+0.1
for j=2:2242
if x(i)>alpha_20(j)
X2_20(i)=alpha_20(j+1)
X1_20(i)=alpha_20(j)
Y2_20(i)=T_20(j+1)
Y1_20(i)=T_20(j)
end
end
T (i)=(((Y2_20(i)-Y1_20(i))/(X2_20(i)-X1_20(i)))*(x(i)-X1_20(i)))+Y1_20(i)
end
Thanks
댓글 수: 0
답변 (1개)
Star Strider
2015년 3월 25일
You already know you want it to return ‘T’, so you need to define what (if any) inputs you want for your function
댓글 수: 8
Star Strider
2015년 3월 27일
You can always return the ‘T_a’ values just by adding it to the returned values:
function [T,D,T_a] = ExcelRead(prefix)
and as before:
[T{k1},D{k1},T_a{k1}] = ExcelRead(prefix);
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!