Printing the values on the .csv file

6 views (last 30 days)
Ganesh Kini
Ganesh Kini on 8 Jun 2020
Answered: dpb on 8 Jun 2020
Temperature Condition
40 Cold
60 warm
80 hot and so on (100 values)
I have a query and i am looking for a solution
So we have 3 back-end files where for temperature 40, the condition cold is defined and so on and is defined based on few conditions ( conditions not important )
but while running the code The output that I get is only temperature values. I do not get the condition value from the program, I need to map the temperature to condition somewhere in the program. So when i run the code for whichever temperature it is set( rather we get the output) it should print the Condtion value in the above format
[fid, msg] = fopen('file1.csv', 'wt' );
fprintf (fid1, 'Temperature');
fprintf('\n');
for
for ...
fprintf (fid, '% 3.0f \ n' , temp)
end
end
fclose(fid);
How do i do that? please help

Answers (1)

dpb
dpb on 8 Jun 2020
In your program you'll have to create a table of the names/categories and the breakpoints that is associated with them and then use a lookup to assign the name based on the value. You've not specified the actual logic of the association, is it <=Breakpoint, maybe?
If so, one way would be something like
tNames={'Cold,'Warm',Hot'};
tBreaks=[40, 60, 80];
...
% compute/read temperatures here...
...
conditions=interp1(tBreaks,tNames,temps,'next');
The above will need bounding elements to cover the range of possible inputs but gives general idea.

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!