필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Easy question about loading data

조회 수: 2 (최근 30일)
Albaihaqi Albaihaqi
Albaihaqi Albaihaqi 2011년 5월 13일
마감: MATLAB Answer Bot 2021년 8월 20일
I am not matlab user so I can not do this. I need help.
So I have this syntax:
% testing the gaver-stehfest module
function y=testgstd(L)
% L is the number of coefficients
% (examples: L=8, 10, 12, 14, 16, so on..)
sum=0.0;
L=16;
for l=1:20
t(l)=l * 0.1;
calcv(l)=gavsteh('fun1',t(l),L);
exactv(l)=t(l);
sum=sum+(1- exactv/calcv)^2;
end
result1=[exactv' calcv' calcv'-exactv']
relerr=sqrt(sum)
How do I make the input for calcv is not from t(l)=l*0.1, but from the data I have built, sort of numbers:
1
2
5
10
20
50
100
200
500
...
thank you for your help
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 5월 13일
What format is your data in?

답변 (1개)

Peter O
Peter O 2011년 5월 13일
Hi,
If your data is in a vector, you can just pass that data along when you call the testing function:
function
y=testgstd(L,dataVector)
% L is the number of coefficients
% (examples: L=8, 10, 12, 14, 16, so on..)
sum=0.0;
This line here will set L as 16 from hereon, regardless of what %you passed to the function above.
L=16;
I've changed your index variable to i below. It's less likely to be confused with the number '1'. I have also adjusted the for loop to run through the whole data vector.
for i=1:length(dataVector)
t(i)=i * 0.1;
calcv(i)=gavsteh('fun1',dataVector(i),L);
The line below as you wrote it is just going to give you from 0.1 to 10% of the number of elements in dataVector, in 0.1 increments. Is this what you want?
exactv(i)=t(i);
sum=sum+(1- exactv/calcv)^2;
end
result1=[exactv' calcv' calcv'-exactv']
relerr=sqrt(sum)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by