Printing the values on the .csv file

6 次查看(过去 30 天)
Ganesh Kini
Ganesh Kini 2020-6-8
回答: dpb 2020-6-8
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

回答(1 个)

dpb
dpb 2020-6-8
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.

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by