Printing the values on the .csv file

조회 수: 7 (최근 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