Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (2)

Jan
Jan il 8 Mar 2015
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 il 8 Mar 2015
Sorry the first line is actually,
function stormdata = readstormdata
I want to capture the result of readstormdata into stormdata

Categorie

Scopri di più su Graphics Object Identification in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by