# if variable i = zero then change row j of the same row to 0 - table

조회 수: 2(최근 30일)
Mathieu St-AMour 2021년 5월 21일
편집: David Fletcher 2021년 5월 21일
So I have a 5007717 x 16 Table and I changed all negative value of column 16 to zero. But now if column 16 is zero I want to change columne 3 of the same row to zero.
SO I tried things like
for i = 1:5007717
if pvdaqdata10(i,16) == 0
pvdaqdata10(i,3) = 0 ;
end
end
but it does'nt seem to work with table
Error: Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
Operator '==' is not supported for operands of type 'table'.
So my question is, how in a table do you change the value of a cell with respect to the value of a other cell of the same row and do that for each row ?
Regards

댓글을 달려면 로그인하십시오.

### 채택된 답변

David Fletcher 2021년 5월 21일
편집: David Fletcher 2021년 5월 21일
col16zero=(pvdaqdata10{:,16}==0)
pvdaqdata10{col16zero,3}=0

댓글을 달려면 로그인하십시오.

### 범주

Find more on Loops and Conditional Statements 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!
{"ft_lang_label":"__label__en","ft_lang_prob":0.6059768,"math_prob":0.67040336,"size":1168,"snap":"2022-40-2023-06","text_gpt3_token_len":408,"char_repetition_ratio":0.11082474,"word_repetition_ratio":0.05909091,"special_character_ratio":0.3125,"punctuation_ratio":0.08880309,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95958716,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-31T23:35:56Z\",\"WARC-Record-ID\":\"<urn:uuid:9a9d0737-2e15-4ab8-92d1-363a824c7c50>\",\"Content-Length\":\"119600\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:899bcfd1-b9ee-4f8a-816d-05ab8db2e153>\",\"WARC-Concurrent-To\":\"<urn:uuid:03f180eb-c4f6-4453-b5dc-1102a4eb3dff>\",\"WARC-IP-Address\":\"23.34.160.82\",\"WARC-Target-URI\":\"https://kr.mathworks.com/matlabcentral/answers/836413-if-variable-i-zero-then-change-row-j-of-the-same-row-to-0-table\",\"WARC-Payload-Digest\":\"sha1:NZDPIBMBZ4LEYS57CCC62QHCYRRDTA64\",\"WARC-Block-Digest\":\"sha1:FEVU75ZPW3TX2AVZJ6WQABNFFLJ543KZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764499891.42_warc_CC-MAIN-20230131222253-20230201012253-00658.warc.gz\"}"}