필터 지우기
필터 지우기

matlab stores the value in ans instead of the variable I assigned

조회 수: 2 (최근 30일)
Nabin SUNAM
Nabin SUNAM 2015년 3월 8일
답변: Nabin SUNAM 2015년 3월 8일
I wrote the following function so that I can use the structure 'stormdata' into another function. But matlab is assigning my data into ans instead of stormdata. What is going on here??
function stormdata = readstormdata(mystormdata)
load mystormdata.dat,
[rows, cols] = size(mystormdata);
for i = 1:rows
stormdata(i) = struct('location',mystormdata(i,1),'inches',...
mystormdata(i,2),'hours',mystormdata(i,3),'intensity',...
mystormdata(i,2)/mystormdata(i,3));)/mystormdata(i,3);
end
end

답변 (2개)

Jan
Jan 2015년 3월 8일
The question is not clear: Where in the posted code does the variable "ans" appear?
How do you call your function? Like this:
stormdata = readstormdata(mystormdata)
Then it looks strange, that "mystormdata" is the input variable and the name of the .dat file. It is smarter to catch the output of load in a variable, because e.g. the readers in the forum cannot guess, what is written magically to the worksapce by this load.

Nabin SUNAM
Nabin SUNAM 2015년 3월 8일
Sorry the first line is actually,
function stormdata = readstormdata
I want to capture the result of readstormdata into stormdata

카테고리

Help CenterFile Exchange에서 Graphics Object Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by